code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def getcaps(): """Return a dictionary containing the mailcap database. The dictionary maps a MIME type (in all lowercase, e.g. 'text/plain') to a list of dictionaries corresponding to mailcap entries. The list collects all the entries for that MIME type from all available mailcap files. Each dict...
Return a dictionary containing the mailcap database. The dictionary maps a MIME type (in all lowercase, e.g. 'text/plain') to a list of dictionaries corresponding to mailcap entries. The list collects all the entries for that MIME type from all available mailcap files. Each dictionary contains key-va...
getcaps
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailcap.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailcap.py
MIT
def listmailcapfiles(): """Return a list of all mailcap files found on the system.""" # XXX Actually, this is Unix-specific if 'MAILCAPS' in os.environ: str = os.environ['MAILCAPS'] mailcaps = str.split(':') else: if 'HOME' in os.environ: home = os.environ['HOME'] ...
Return a list of all mailcap files found on the system.
listmailcapfiles
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailcap.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailcap.py
MIT
def readmailcapfile(fp): """Read a mailcap file and return a dictionary keyed by MIME type. Each MIME type is mapped to an entry consisting of a list of dictionaries; the list will contain more than one such dictionary if a given MIME type appears more than once in the mailcap file. Each dictionary...
Read a mailcap file and return a dictionary keyed by MIME type. Each MIME type is mapped to an entry consisting of a list of dictionaries; the list will contain more than one such dictionary if a given MIME type appears more than once in the mailcap file. Each dictionary contains key-value pairs for th...
readmailcapfile
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailcap.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailcap.py
MIT
def parseline(line): """Parse one entry in a mailcap file and return a dictionary. The viewing command is stored as the value with the key "view", and the rest of the fields produce key-value pairs in the dict. """ fields = [] i, n = 0, len(line) while i < n: field, i = parsefield(l...
Parse one entry in a mailcap file and return a dictionary. The viewing command is stored as the value with the key "view", and the rest of the fields produce key-value pairs in the dict.
parseline
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailcap.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailcap.py
MIT
def parsefield(line, i, n): """Separate one key-value pair in a mailcap entry.""" start = i while i < n: c = line[i] if c == ';': break elif c == '\\': i = i+2 else: i = i+1 return line[start:i].strip(), i
Separate one key-value pair in a mailcap entry.
parsefield
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailcap.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailcap.py
MIT
def findmatch(caps, MIMEtype, key='view', filename="/dev/null", plist=[]): """Find a match for a mailcap entry. Return a tuple containing the command line, and the mailcap entry used; (None, None) if no match is found. This may invoke the 'test' command of several matching entries before deciding whic...
Find a match for a mailcap entry. Return a tuple containing the command line, and the mailcap entry used; (None, None) if no match is found. This may invoke the 'test' command of several matching entries before deciding which entry to use.
findmatch
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailcap.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailcap.py
MIT
def getcontext(self): """Return the name of the current folder.""" context = pickline(os.path.join(self.getpath(), 'context'), 'Current-Folder') if not context: context = 'inbox' return context
Return the name of the current folder.
getcontext
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def setcontext(self, context): """Set the name of the current folder.""" fn = os.path.join(self.getpath(), 'context') f = open(fn, "w") f.write("Current-Folder: %s\n" % context) f.close()
Set the name of the current folder.
setcontext
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def listfolders(self): """Return the names of the top-level folders.""" folders = [] path = self.getpath() for name in os.listdir(path): fullname = os.path.join(path, name) if os.path.isdir(fullname): folders.append(name) folders.sort() ...
Return the names of the top-level folders.
listfolders
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def listsubfolders(self, name): """Return the names of the subfolders in a given folder (prefixed with the given folder name).""" fullname = os.path.join(self.path, name) # Get the link count so we can avoid listing folders # that have no subfolders. nlinks = os.stat(full...
Return the names of the subfolders in a given folder (prefixed with the given folder name).
listsubfolders
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def listallsubfolders(self, name): """Return the names of subfolders in a given folder, recursively.""" fullname = os.path.join(self.path, name) # Get the link count so we can avoid listing folders # that have no subfolders. nlinks = os.stat(fullname).st_nlink if nlinks =...
Return the names of subfolders in a given folder, recursively.
listallsubfolders
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def makefolder(self, name): """Create a new folder (or raise os.error if it cannot be created).""" protect = pickline(self.profile, 'Folder-Protect') if protect and isnumeric(protect): mode = int(protect, 8) else: mode = FOLDER_PROTECT os.mkdir(os.path.joi...
Create a new folder (or raise os.error if it cannot be created).
makefolder
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def deletefolder(self, name): """Delete a folder. This removes files in the folder but not subdirectories. Raise os.error if deleting the folder itself fails.""" fullname = os.path.join(self.getpath(), name) for subname in os.listdir(fullname): fullsubname = os.path.join(fu...
Delete a folder. This removes files in the folder but not subdirectories. Raise os.error if deleting the folder itself fails.
deletefolder
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def listmessages(self): """Return the list of messages currently present in the folder. As a side effect, set self.last to the last message (or 0).""" messages = [] match = numericprog.match append = messages.append for name in os.listdir(self.getfullname()): ...
Return the list of messages currently present in the folder. As a side effect, set self.last to the last message (or 0).
listmessages
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def getsequences(self): """Return the set of sequences for the folder.""" sequences = {} fullname = self.getsequencesfilename() try: f = open(fullname, 'r') except IOError: return sequences while 1: line = f.readline() if no...
Return the set of sequences for the folder.
getsequences
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def putsequences(self, sequences): """Write the set of sequences back to the folder.""" fullname = self.getsequencesfilename() f = None for key, seq in sequences.iteritems(): s = IntSet('', ' ') s.fromlist(seq) if not f: f = open(fullname, 'w') ...
Write the set of sequences back to the folder.
putsequences
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def getcurrent(self): """Return the current message. Raise Error when there is none.""" seqs = self.getsequences() try: return max(seqs['cur']) except (ValueError, KeyError): raise Error, "no cur message"
Return the current message. Raise Error when there is none.
getcurrent
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def parsesequence(self, seq): """Parse an MH sequence specification into a message list. Attempt to mimic mh-sequence(5) as close as possible. Also attempt to mimic observed behavior regarding which conditions cause which error messages.""" # XXX Still not complete (see mh-format...
Parse an MH sequence specification into a message list. Attempt to mimic mh-sequence(5) as close as possible. Also attempt to mimic observed behavior regarding which conditions cause which error messages.
parsesequence
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def _parseindex(self, seq, all): """Internal: parse a message number (or cur, first, etc.).""" if isnumeric(seq): try: return int(seq) except (OverflowError, ValueError): return sys.maxint if seq in ('cur', '.'): return self.get...
Internal: parse a message number (or cur, first, etc.).
_parseindex
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def removemessages(self, list): """Remove one or more messages -- may raise os.error.""" errors = [] deleted = [] for n in list: path = self.getmessagefilename(n) commapath = self.getmessagefilename(',' + str(n)) try: os.unlink(commapat...
Remove one or more messages -- may raise os.error.
removemessages
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def refilemessages(self, list, tofolder, keepsequences=0): """Refile one or more messages -- may raise os.error. 'tofolder' is an open folder object.""" errors = [] refiled = {} for n in list: ton = tofolder.getlast() + 1 path = self.getmessagefilename(n) ...
Refile one or more messages -- may raise os.error. 'tofolder' is an open folder object.
refilemessages
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def _copysequences(self, fromfolder, refileditems): """Helper for refilemessages() to copy sequences.""" fromsequences = fromfolder.getsequences() tosequences = self.getsequences() changed = 0 for name, seq in fromsequences.items(): try: toseq = tosequ...
Helper for refilemessages() to copy sequences.
_copysequences
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def movemessage(self, n, tofolder, ton): """Move one message over a specific destination message, which may or may not already exist.""" path = self.getmessagefilename(n) # Open it to check that it exists f = open(path) f.close() del f topath = tofolder.ge...
Move one message over a specific destination message, which may or may not already exist.
movemessage
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def copymessage(self, n, tofolder, ton): """Copy one message over a specific destination message, which may or may not already exist.""" path = self.getmessagefilename(n) # Open it to check that it exists f = open(path) f.close() del f topath = tofolder.ge...
Copy one message over a specific destination message, which may or may not already exist.
copymessage
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def createmessage(self, n, txt): """Create a message, with text from the open file txt.""" path = self.getmessagefilename(n) backuppath = self.getmessagefilename(',%d' % n) try: os.rename(path, backuppath) except os.error: pass ok = 0 BUFSI...
Create a message, with text from the open file txt.
createmessage
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def removefromallsequences(self, list): """Remove one or more messages from all sequences (including last) -- but not from 'cur'!!!""" if hasattr(self, 'last') and self.last in list: del self.last sequences = self.getsequences() changed = 0 for name, seq in se...
Remove one or more messages from all sequences (including last) -- but not from 'cur'!!!
removefromallsequences
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def getheadertext(self, pred = None): """Return the message's header text as a string. If an argument is specified, it is used as a filter predicate to decide which headers to return (its argument is the header name converted to lower case).""" if pred is None: retur...
Return the message's header text as a string. If an argument is specified, it is used as a filter predicate to decide which headers to return (its argument is the header name converted to lower case).
getheadertext
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def getbodytext(self, decode = 1): """Return the message's body text as string. This undoes a Content-Transfer-Encoding, but does not interpret other MIME features (e.g. multipart messages). To suppress decoding, pass 0 as an argument.""" self.fp.seek(self.startofbody) ...
Return the message's body text as string. This undoes a Content-Transfer-Encoding, but does not interpret other MIME features (e.g. multipart messages). To suppress decoding, pass 0 as an argument.
getbodytext
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def getbodyparts(self): """Only for multipart messages: return the message's body as a list of SubMessage objects. Each submessage object behaves (almost) as a Message object.""" if self.getmaintype() != 'multipart': raise Error, 'Content-Type is not multipart/*' bdr...
Only for multipart messages: return the message's body as a list of SubMessage objects. Each submessage object behaves (almost) as a Message object.
getbodyparts
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def getbody(self): """Return body, either a string or a list of messages.""" if self.getmaintype() == 'multipart': return self.getbodyparts() else: return self.getbodytext()
Return body, either a string or a list of messages.
getbody
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mhlib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mhlib.py
MIT
def choose_boundary(): """Return a string usable as a multipart boundary. The string chosen is unique within a single program run, and incorporates the user id (if available), process id (if available), and current time. So it's very unlikely the returned string appears in message text, but there'...
Return a string usable as a multipart boundary. The string chosen is unique within a single program run, and incorporates the user id (if available), process id (if available), and current time. So it's very unlikely the returned string appears in message text, but there's no guarantee. The bound...
choose_boundary
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimetools.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimetools.py
MIT
def decode(input, output, encoding): """Decode common content-transfer-encodings (base64, quopri, uuencode).""" if encoding == 'base64': import base64 return base64.decode(input, output) if encoding == 'quoted-printable': import quopri return quopri.decode(input, output) ...
Decode common content-transfer-encodings (base64, quopri, uuencode).
decode
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimetools.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimetools.py
MIT
def encode(input, output, encoding): """Encode common content-transfer-encodings (base64, quopri, uuencode).""" if encoding == 'base64': import base64 return base64.encode(input, output) if encoding == 'quoted-printable': import quopri return quopri.encode(input, output, 0) ...
Encode common content-transfer-encodings (base64, quopri, uuencode).
encode
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimetools.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimetools.py
MIT
def add_type(self, type, ext, strict=True): """Add a mapping between a type and an extension. When the extension is already known, the new type will replace the old one. When the type is already known the extension will be added to the list of known extensions. If stric...
Add a mapping between a type and an extension. When the extension is already known, the new type will replace the old one. When the type is already known the extension will be added to the list of known extensions. If strict is true, information will be added to list of...
add_type
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimetypes.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimetypes.py
MIT
def guess_type(self, url, strict=True): """Guess the type of a file based on its URL. Return value is a tuple (type, encoding) where type is None if the type can't be guessed (no or unknown suffix) or a string of the form type/subtype, usable for a MIME Content-type header; and ...
Guess the type of a file based on its URL. Return value is a tuple (type, encoding) where type is None if the type can't be guessed (no or unknown suffix) or a string of the form type/subtype, usable for a MIME Content-type header; and encoding is None for no encoding or the name of ...
guess_type
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimetypes.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimetypes.py
MIT
def guess_all_extensions(self, type, strict=True): """Guess the extensions for a file based on its MIME type. Return value is a list of strings giving the possible filename extensions, including the leading dot ('.'). The extension is not guaranteed to have been associated with any par...
Guess the extensions for a file based on its MIME type. Return value is a list of strings giving the possible filename extensions, including the leading dot ('.'). The extension is not guaranteed to have been associated with any particular data stream, but would be mapped to the MIME t...
guess_all_extensions
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimetypes.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimetypes.py
MIT
def guess_extension(self, type, strict=True): """Guess the extension for a file based on its MIME type. Return value is a string giving a filename extension, including the leading dot ('.'). The extension is not guaranteed to have been associated with any particular data stream...
Guess the extension for a file based on its MIME type. Return value is a string giving a filename extension, including the leading dot ('.'). The extension is not guaranteed to have been associated with any particular data stream, but would be mapped to the MIME type `type' by ...
guess_extension
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimetypes.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimetypes.py
MIT
def readfp(self, fp, strict=True): """ Read a single mime.types-format file. If strict is true, information will be added to list of standard types, else to the list of non-standard types. """ while 1: line = fp.readline() if not line: ...
Read a single mime.types-format file. If strict is true, information will be added to list of standard types, else to the list of non-standard types.
readfp
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimetypes.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimetypes.py
MIT
def read_windows_registry(self, strict=True): """ Load the MIME types database from Windows registry. If strict is true, information will be added to list of standard types, else to the list of non-standard types. """ # Windows only if not _winreg: ...
Load the MIME types database from Windows registry. If strict is true, information will be added to list of standard types, else to the list of non-standard types.
read_windows_registry
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimetypes.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimetypes.py
MIT
def guess_type(url, strict=True): """Guess the type of a file based on its URL. Return value is a tuple (type, encoding) where type is None if the type can't be guessed (no or unknown suffix) or a string of the form type/subtype, usable for a MIME Content-type header; and encoding is None for no en...
Guess the type of a file based on its URL. Return value is a tuple (type, encoding) where type is None if the type can't be guessed (no or unknown suffix) or a string of the form type/subtype, usable for a MIME Content-type header; and encoding is None for no encoding or the name of the program used ...
guess_type
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimetypes.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimetypes.py
MIT
def guess_all_extensions(type, strict=True): """Guess the extensions for a file based on its MIME type. Return value is a list of strings giving the possible filename extensions, including the leading dot ('.'). The extension is not guaranteed to have been associated with any particular data strea...
Guess the extensions for a file based on its MIME type. Return value is a list of strings giving the possible filename extensions, including the leading dot ('.'). The extension is not guaranteed to have been associated with any particular data stream, but would be mapped to the MIME type `type' by ...
guess_all_extensions
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimetypes.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimetypes.py
MIT
def guess_extension(type, strict=True): """Guess the extension for a file based on its MIME type. Return value is a string giving a filename extension, including the leading dot ('.'). The extension is not guaranteed to have been associated with any particular data stream, but would be mapped to the ...
Guess the extension for a file based on its MIME type. Return value is a string giving a filename extension, including the leading dot ('.'). The extension is not guaranteed to have been associated with any particular data stream, but would be mapped to the MIME type `type' by guess_type(). If no ext...
guess_extension
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimetypes.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimetypes.py
MIT
def add_type(type, ext, strict=True): """Add a mapping between a type and an extension. When the extension is already known, the new type will replace the old one. When the type is already known the extension will be added to the list of known extensions. If strict is true, information will be...
Add a mapping between a type and an extension. When the extension is already known, the new type will replace the old one. When the type is already known the extension will be added to the list of known extensions. If strict is true, information will be added to list of standard types, else to...
add_type
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimetypes.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimetypes.py
MIT
def addheader(self, key, value, prefix=0): """Add a header line to the MIME message. The key is the name of the header, where the value obviously provides the value of the header. The optional argument prefix determines where the header is inserted; 0 means append at the end, 1 means ...
Add a header line to the MIME message. The key is the name of the header, where the value obviously provides the value of the header. The optional argument prefix determines where the header is inserted; 0 means append at the end, 1 means insert at the start. The default is to append. ...
addheader
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/MimeWriter.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/MimeWriter.py
MIT
def flushheaders(self): """Writes out and forgets all headers accumulated so far. This is useful if you don't need a body part at all; for example, for a subpart of type message/rfc822 that's (mis)used to store some header-like information. """ self._fp.writelines(self....
Writes out and forgets all headers accumulated so far. This is useful if you don't need a body part at all; for example, for a subpart of type message/rfc822 that's (mis)used to store some header-like information.
flushheaders
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/MimeWriter.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/MimeWriter.py
MIT
def startbody(self, ctype, plist=[], prefix=1): """Returns a file-like object for writing the body of the message. The content-type is set to the provided ctype, and the optional parameter, plist, provides additional parameters for the content-type declaration. The optional argument pr...
Returns a file-like object for writing the body of the message. The content-type is set to the provided ctype, and the optional parameter, plist, provides additional parameters for the content-type declaration. The optional argument prefix determines where the header is inserted; 0 mea...
startbody
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/MimeWriter.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/MimeWriter.py
MIT
def startmultipartbody(self, subtype, boundary=None, plist=[], prefix=1): """Returns a file-like object for writing the body of the message. Additionally, this method initializes the multi-part code, where the subtype parameter provides the multipart subtype, the boundary parameter may ...
Returns a file-like object for writing the body of the message. Additionally, this method initializes the multi-part code, where the subtype parameter provides the multipart subtype, the boundary parameter may provide a user-defined boundary specification, and the plist parameter provid...
startmultipartbody
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/MimeWriter.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/MimeWriter.py
MIT
def mime_decode(line): """Decode a single line of quoted-printable text to 8bit.""" newline = '' pos = 0 while 1: res = mime_code.search(line, pos) if res is None: break newline = newline + line[pos:res.start(0)] + \ chr(int(res.group(1), 16)) ...
Decode a single line of quoted-printable text to 8bit.
mime_decode
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimify.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimify.py
MIT
def unmimify_part(ifile, ofile, decode_base64 = 0): """Convert a quoted-printable part of a MIME mail message to 8bit.""" multipart = None quoted_printable = 0 is_base64 = 0 is_repl = 0 if ifile.boundary and ifile.boundary[:2] == QUOTE: prefix = QUOTE else: prefix = '' #...
Convert a quoted-printable part of a MIME mail message to 8bit.
unmimify_part
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimify.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimify.py
MIT
def unmimify(infile, outfile, decode_base64 = 0): """Convert quoted-printable parts of a MIME mail message to 8bit.""" if type(infile) == type(''): ifile = open(infile) if type(outfile) == type('') and infile == outfile: import os d, f = os.path.split(infile) ...
Convert quoted-printable parts of a MIME mail message to 8bit.
unmimify
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimify.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimify.py
MIT
def mime_encode(line, header): """Code a single line as quoted-printable. If header is set, quote some extra characters.""" if header: reg = mime_header_char else: reg = mime_char newline = '' pos = 0 if len(line) >= 5 and line[:5] == 'From ': # quote 'From ' at the s...
Code a single line as quoted-printable. If header is set, quote some extra characters.
mime_encode
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimify.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimify.py
MIT
def mime_encode_header(line): """Code a single header line as quoted-printable.""" newline = '' pos = 0 while 1: res = mime_header.search(line, pos) if res is None: break newline = '%s%s%s=?%s?Q?%s?=' % \ (newline, line[pos:res.start(0)], res.group(1...
Code a single header line as quoted-printable.
mime_encode_header
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimify.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimify.py
MIT
def mimify_part(ifile, ofile, is_mime): """Convert an 8bit part of a MIME mail message to quoted-printable.""" has_cte = is_qp = is_base64 = 0 multipart = None must_quote_body = must_quote_header = has_iso_chars = 0 header = [] header_end = '' message = [] message_end = '' # read he...
Convert an 8bit part of a MIME mail message to quoted-printable.
mimify_part
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimify.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimify.py
MIT
def mimify(infile, outfile): """Convert 8bit parts of a MIME mail message to quoted-printable.""" if type(infile) == type(''): ifile = open(infile) if type(outfile) == type('') and infile == outfile: import os d, f = os.path.split(infile) os.rename(infile, os....
Convert 8bit parts of a MIME mail message to quoted-printable.
mimify
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mimify.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mimify.py
MIT
def report(self): """Print a report to stdout, listing the found modules with their paths, as well as modules that are missing, or seem to be missing. """ print print " %-25s %s" % ("Name", "File") print " %-25s %s" % ("----", "----") # Print modules found ...
Print a report to stdout, listing the found modules with their paths, as well as modules that are missing, or seem to be missing.
report
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/modulefinder.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/modulefinder.py
MIT
def any_missing(self): """Return a list of modules that appear to be missing. Use any_missing_maybe() if you want to know which modules are certain to be missing, and which *may* be missing. """ missing, maybe = self.any_missing_maybe() return missing + maybe
Return a list of modules that appear to be missing. Use any_missing_maybe() if you want to know which modules are certain to be missing, and which *may* be missing.
any_missing
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/modulefinder.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/modulefinder.py
MIT
def any_missing_maybe(self): """Return two lists, one with modules that are certainly missing and one with modules that *may* be missing. The latter names could either be submodules *or* just global names in the package. The reason it can't always be determined is that it's impossible t...
Return two lists, one with modules that are certainly missing and one with modules that *may* be missing. The latter names could either be submodules *or* just global names in the package. The reason it can't always be determined is that it's impossible to tell which names are imported ...
any_missing_maybe
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/modulefinder.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/modulefinder.py
MIT
def testandset(self): """Atomic test-and-set -- grab the lock if it is not set, return True if it succeeded.""" if not self.locked: self.locked = True return True else: return False
Atomic test-and-set -- grab the lock if it is not set, return True if it succeeded.
testandset
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mutex.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mutex.py
MIT
def lock(self, function, argument): """Lock a mutex, call the function with supplied argument when it is acquired. If the mutex is already locked, place function and argument in the queue.""" if self.testandset(): function(argument) else: self.queue.appen...
Lock a mutex, call the function with supplied argument when it is acquired. If the mutex is already locked, place function and argument in the queue.
lock
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mutex.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mutex.py
MIT
def unlock(self): """Unlock a mutex. If the queue is not empty, call the next function with its argument.""" if self.queue: function, argument = self.queue.popleft() function(argument) else: self.locked = False
Unlock a mutex. If the queue is not empty, call the next function with its argument.
unlock
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mutex.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mutex.py
MIT
def authenticators(self, host): """Return a (user, account, password) tuple for given host.""" if host in self.hosts: return self.hosts[host] elif 'default' in self.hosts: return self.hosts['default'] else: return None
Return a (user, account, password) tuple for given host.
authenticators
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/netrc.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/netrc.py
MIT
def __repr__(self): """Dump the class data in the format of a .netrc file.""" rep = "" for host in self.hosts.keys(): attrs = self.hosts[host] rep = rep + "machine "+ host + "\n\tlogin " + repr(attrs[0]) + "\n" if attrs[1]: rep = rep + "account...
Dump the class data in the format of a .netrc file.
__repr__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/netrc.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/netrc.py
MIT
def __init__(self, host, port=NNTP_PORT, user=None, password=None, readermode=None, usenetrc=True): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port) - user: username to authenticate with ...
Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port) - user: username to authenticate with - password: password to use with username - readermode: if true, send 'mode reader' command after ...
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def putline(self, line): """Internal: send one line to the server, appending CRLF.""" line = line + CRLF if self.debugging > 1: print '*put*', repr(line) self.sock.sendall(line)
Internal: send one line to the server, appending CRLF.
putline
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def getline(self): """Internal: return one line from the server, stripping CRLF. Raise EOFError if the connection is closed.""" line = self.file.readline(_MAXLINE + 1) if len(line) > _MAXLINE: raise NNTPDataError('line too long') if self.debugging > 1: pri...
Internal: return one line from the server, stripping CRLF. Raise EOFError if the connection is closed.
getline
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def getresp(self): """Internal: get a response from the server. Raise various errors if the response indicates an error.""" resp = self.getline() if self.debugging: print '*resp*', repr(resp) c = resp[:1] if c == '4': raise NNTPTemporaryError(resp) if ...
Internal: get a response from the server. Raise various errors if the response indicates an error.
getresp
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def getlongresp(self, file=None): """Internal: get a response plus following text from the server. Raise various errors if the response indicates an error.""" openedFile = None try: # If a string was passed then open a file with that name if isinstance(file, str)...
Internal: get a response plus following text from the server. Raise various errors if the response indicates an error.
getlongresp
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def newnews(self, group, date, time, file=None): """Process a NEWNEWS command. Arguments: - group: group name or '*' - date: string 'yymmdd' indicating the date - time: string 'hhmmss' indicating the time Return: - resp: server response if successful - list: list...
Process a NEWNEWS command. Arguments: - group: group name or '*' - date: string 'yymmdd' indicating the date - time: string 'hhmmss' indicating the time Return: - resp: server response if successful - list: list of message ids
newnews
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def list(self, file=None): """Process a LIST command. Return: - resp: server response if successful - list: list of (group, last, first, flag) (strings)""" resp, list = self.longcmd('LIST', file) for i in range(len(list)): # Parse lines into "group last first flag" ...
Process a LIST command. Return: - resp: server response if successful - list: list of (group, last, first, flag) (strings)
list
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def description(self, group): """Get a description for a single group. If more than one group matches ('group' is a pattern), return the first. If no group matches, return an empty string. This elides the response code from the server, since it can only be '215' or '285' (for...
Get a description for a single group. If more than one group matches ('group' is a pattern), return the first. If no group matches, return an empty string. This elides the response code from the server, since it can only be '215' or '285' (for xgtitle) anyway. If the response ...
description
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def descriptions(self, group_pattern): """Get descriptions for a range of groups.""" line_pat = re.compile("^(?P<group>[^ \t]+)[ \t]+(.*)$") # Try the more std (acc. to RFC2980) LIST NEWSGROUPS first resp, raw_lines = self.longcmd('LIST NEWSGROUPS ' + group_pattern) if resp[:3] !...
Get descriptions for a range of groups.
descriptions
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def group(self, name): """Process a GROUP command. Argument: - group: the group name Returns: - resp: server response if successful - count: number of articles (string) - first: first article number (string) - last: last article number (string) - name: th...
Process a GROUP command. Argument: - group: the group name Returns: - resp: server response if successful - count: number of articles (string) - first: first article number (string) - last: last article number (string) - name: the group name
group
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def statparse(self, resp): """Internal: parse the response of a STAT, NEXT or LAST command.""" if resp[:2] != '22': raise NNTPReplyError(resp) words = resp.split() nr = 0 id = '' n = len(words) if n > 1: nr = words[1] if n > 2: ...
Internal: parse the response of a STAT, NEXT or LAST command.
statparse
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def artcmd(self, line, file=None): """Internal: process a HEAD, BODY or ARTICLE command.""" resp, list = self.longcmd(line, file) resp, nr, id = self.statparse(resp) return resp, nr, id, list
Internal: process a HEAD, BODY or ARTICLE command.
artcmd
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def xhdr(self, hdr, str, file=None): """Process an XHDR command (optional server extension). Arguments: - hdr: the header type (e.g. 'subject') - str: an article nr, a message id, or a range nr1-nr2 Returns: - resp: server response if successful - list: list of (nr, valu...
Process an XHDR command (optional server extension). Arguments: - hdr: the header type (e.g. 'subject') - str: an article nr, a message id, or a range nr1-nr2 Returns: - resp: server response if successful - list: list of (nr, value) strings
xhdr
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def xover(self, start, end, file=None): """Process an XOVER command (optional server extension) Arguments: - start: start of range - end: end of range Returns: - resp: server response if successful - list: list of (art-nr, subject, poster, date, i...
Process an XOVER command (optional server extension) Arguments: - start: start of range - end: end of range Returns: - resp: server response if successful - list: list of (art-nr, subject, poster, date, id, references, size, lines)
xover
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def xgtitle(self, group, file=None): """Process an XGTITLE command (optional server extension) Arguments: - group: group name wildcard (i.e. news.*) Returns: - resp: server response if successful - list: list of (name,title) strings""" line_pat = re.compile("^([^ \t]+)[ ...
Process an XGTITLE command (optional server extension) Arguments: - group: group name wildcard (i.e. news.*) Returns: - resp: server response if successful - list: list of (name,title) strings
xgtitle
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def xpath(self,id): """Process an XPATH command (optional server extension) Arguments: - id: Message id of article Returns: resp: server response if successful path: directory path to article""" resp = self.shortcmd("XPATH " + id) if resp[:3] != '223': ...
Process an XPATH command (optional server extension) Arguments: - id: Message id of article Returns: resp: server response if successful path: directory path to article
xpath
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def date (self): """Process the DATE command. Arguments: None Returns: resp: server response if successful date: Date suitable for newnews/newgroups commands etc. time: Time suitable for newnews/newgroups commands etc.""" resp = self.shortcmd("DATE") if r...
Process the DATE command. Arguments: None Returns: resp: server response if successful date: Date suitable for newnews/newgroups commands etc. time: Time suitable for newnews/newgroups commands etc.
date
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def post(self, f): """Process a POST command. Arguments: - f: file containing the article Returns: - resp: server response if successful""" resp = self.shortcmd('POST') # Raises error_??? if posting is not allowed if resp[0] != '3': raise NNTPReplyEr...
Process a POST command. Arguments: - f: file containing the article Returns: - resp: server response if successful
post
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def ihave(self, id, f): """Process an IHAVE command. Arguments: - id: message-id of the article - f: file containing the article Returns: - resp: server response if successful Note that if the server refuses the article an exception is raised.""" resp = self.sh...
Process an IHAVE command. Arguments: - id: message-id of the article - f: file containing the article Returns: - resp: server response if successful Note that if the server refuses the article an exception is raised.
ihave
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def quit(self): """Process a QUIT command and close the socket. Returns: - resp: server response if successful""" resp = self.shortcmd('QUIT') self.file.close() self.sock.close() del self.file, self.sock return resp
Process a QUIT command and close the socket. Returns: - resp: server response if successful
quit
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nntplib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nntplib.py
MIT
def join(path, *paths): """Join two or more pathname components, inserting "\\" as needed.""" result_drive, result_path = splitdrive(path) for p in paths: p_drive, p_path = splitdrive(p) if p_path and p_path[0] in '\\/': # Second path is absolute if p_drive or not res...
Join two or more pathname components, inserting "\" as needed.
join
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/ntpath.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ntpath.py
MIT
def splitdrive(p): """Split a pathname into drive/UNC sharepoint and relative path specifiers. Returns a 2-tuple (drive_or_unc, path); either part may be empty. If you assign result = splitdrive(p) It is always true that: result[0] + result[1] == p If the path contained a drive let...
Split a pathname into drive/UNC sharepoint and relative path specifiers. Returns a 2-tuple (drive_or_unc, path); either part may be empty. If you assign result = splitdrive(p) It is always true that: result[0] + result[1] == p If the path contained a drive letter, drive_or_unc will con...
splitdrive
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/ntpath.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ntpath.py
MIT
def splitunc(p): """Split a pathname into UNC mount point and relative path specifiers. Return a 2-tuple (unc, rest); either part may be empty. If unc is not empty, it has the form '//host/mount' (or similar using backslashes). unc+rest is always the input path. Paths containing drive letters neve...
Split a pathname into UNC mount point and relative path specifiers. Return a 2-tuple (unc, rest); either part may be empty. If unc is not empty, it has the form '//host/mount' (or similar using backslashes). unc+rest is always the input path. Paths containing drive letters never have a UNC part.
splitunc
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/ntpath.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ntpath.py
MIT
def split(p): """Split a pathname. Return tuple (head, tail) where tail is everything after the final slash. Either part may be empty.""" d, p = splitdrive(p) # set i to index beyond p's last slash i = len(p) while i and p[i-1] not in '/\\': i = i - 1 head, tail = p[:i], p[i:] ...
Split a pathname. Return tuple (head, tail) where tail is everything after the final slash. Either part may be empty.
split
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/ntpath.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ntpath.py
MIT
def ismount(path): """Test whether a path is a mount point (defined as root of drive)""" unc, rest = splitunc(path) if unc: return rest in ("", "/", "\\") p = splitdrive(path)[1] return len(p) == 1 and p[0] in '/\\'
Test whether a path is a mount point (defined as root of drive)
ismount
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/ntpath.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ntpath.py
MIT
def walk(top, func, arg): """Directory tree walk with callback function. For each directory in the directory tree rooted at top (including top itself, but excluding '.' and '..'), call func(arg, dirname, fnames). dirname is the name of the directory, and fnames a list of the names of the files and ...
Directory tree walk with callback function. For each directory in the directory tree rooted at top (including top itself, but excluding '.' and '..'), call func(arg, dirname, fnames). dirname is the name of the directory, and fnames a list of the names of the files and subdirectories in dirname (exclud...
walk
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/ntpath.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ntpath.py
MIT
def expanduser(path): """Expand ~ and ~user constructs. If user or $HOME is unknown, do nothing.""" if path[:1] != '~': return path i, n = 1, len(path) while i < n and path[i] not in '/\\': i = i + 1 if 'HOME' in os.environ: userhome = os.environ['HOME'] elif 'USERP...
Expand ~ and ~user constructs. If user or $HOME is unknown, do nothing.
expanduser
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/ntpath.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ntpath.py
MIT
def expandvars(path): """Expand shell variables of the forms $var, ${var} and %var%. Unknown variables are left unchanged.""" if '$' not in path and '%' not in path: return path import string varchars = string.ascii_letters + string.digits + '_-' if isinstance(path, _unicode): e...
Expand shell variables of the forms $var, ${var} and %var%. Unknown variables are left unchanged.
expandvars
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/ntpath.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ntpath.py
MIT
def normpath(path): """Normalize path, eliminating double slashes, etc.""" # Preserve unicode (if path is unicode) backslash, dot = (u'\\', u'.') if isinstance(path, _unicode) else ('\\', '.') if path.startswith(('\\\\.\\', '\\\\?\\')): # in the case of paths with these prefixes: # \\.\ ...
Normalize path, eliminating double slashes, etc.
normpath
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/ntpath.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ntpath.py
MIT
def abspath(path): """Return the absolute version of a path.""" if not isabs(path): if isinstance(path, _unicode): cwd = os.getcwdu() else: cwd = os.getcwd() path = join(cwd, path) return normpath(path)
Return the absolute version of a path.
abspath
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/ntpath.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ntpath.py
MIT
def abspath(path): """Return the absolute version of a path.""" if path: # Empty path must return current working directory. try: path = _getfullpathname(path) except WindowsError: pass # Bad path - return unchanged. elif isinstance(path, ...
Return the absolute version of a path.
abspath
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/ntpath.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ntpath.py
MIT
def url2pathname(url): """OS-specific conversion from a relative URL of the 'file' scheme to a file system path; not recommended for general use.""" # e.g. # ///C|/foo/bar/spam.foo # and # ///C:/foo/bar/spam.foo # become # C:\foo\bar\spam.foo import string, urllib # Windows...
OS-specific conversion from a relative URL of the 'file' scheme to a file system path; not recommended for general use.
url2pathname
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nturl2path.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nturl2path.py
MIT
def pathname2url(p): """OS-specific conversion from a file system path to a relative URL of the 'file' scheme; not recommended for general use.""" # e.g. # C:\foo\bar\spam.foo # becomes # ///C:/foo/bar/spam.foo import urllib if not ':' in p: # No drive specifier, just convert...
OS-specific conversion from a file system path to a relative URL of the 'file' scheme; not recommended for general use.
pathname2url
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/nturl2path.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/nturl2path.py
MIT
def _format_text(self, text): """ Format a paragraph of free-form text for inclusion in the help output at the current indentation level. """ text_width = max(self.width - self.current_indent, 11) indent = " "*self.current_indent return textwrap.fill(text, ...
Format a paragraph of free-form text for inclusion in the help output at the current indentation level.
_format_text
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/optparse.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/optparse.py
MIT
def format_option_strings(self, option): """Return a comma-separated list of option strings & metavariables.""" if option.takes_value(): metavar = option.metavar or option.dest.upper() short_opts = [self._short_opt_fmt % (sopt, metavar) for sopt in optio...
Return a comma-separated list of option strings & metavariables.
format_option_strings
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/optparse.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/optparse.py
MIT
def _update_careful(self, dict): """ Update the option values from an arbitrary dictionary, but only use keys from dict that already have a corresponding attribute in self. Any keys in dict without a corresponding attribute are silently ignored. """ for attr in d...
Update the option values from an arbitrary dictionary, but only use keys from dict that already have a corresponding attribute in self. Any keys in dict without a corresponding attribute are silently ignored.
_update_careful
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/optparse.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/optparse.py
MIT
def destroy(self): """ Declare that you are done with this OptionParser. This cleans up reference cycles so the OptionParser (and all objects referenced by it) can be garbage-collected promptly. After calling destroy(), the OptionParser is unusable. """ OptionCo...
Declare that you are done with this OptionParser. This cleans up reference cycles so the OptionParser (and all objects referenced by it) can be garbage-collected promptly. After calling destroy(), the OptionParser is unusable.
destroy
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/optparse.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/optparse.py
MIT
def parse_args(self, args=None, values=None): """ parse_args(args : [string] = sys.argv[1:], values : Values = None) -> (values : Values, args : [string]) Parse the command-line options found in 'args' (default: sys.argv[1:]). Any errors result in a call to '...
parse_args(args : [string] = sys.argv[1:], values : Values = None) -> (values : Values, args : [string]) Parse the command-line options found in 'args' (default: sys.argv[1:]). Any errors result in a call to 'error()', which by default prints the usage messa...
parse_args
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/optparse.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/optparse.py
MIT