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 setlocale(category, value=None): """ setlocale(integer,string=None) -> string. Activates/queries locale processing. """ if value not in (None, '', 'C'): raise Error, '_locale emulation only supports "C" locale' return 'C'
setlocale(integer,string=None) -> string. Activates/queries locale processing.
setlocale
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/locale.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/locale.py
MIT
def format(percent, value, grouping=False, monetary=False, *additional): """Returns the locale-aware substitution of a %? specifier (percent). additional is for format strings which contain one or more '*' modifiers.""" # this is only for one-percent-specifier strings and this should be checked ...
Returns the locale-aware substitution of a %? specifier (percent). additional is for format strings which contain one or more '*' modifiers.
format
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/locale.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/locale.py
MIT
def format_string(f, val, grouping=False): """Formats a string in the same way that the % formatting would use, but takes the current locale into account. Grouping is applied if the third parameter is true.""" percents = list(_percent_re.finditer(f)) new_f = _percent_re.sub('%s', f) if operator...
Formats a string in the same way that the % formatting would use, but takes the current locale into account. Grouping is applied if the third parameter is true.
format_string
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/locale.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/locale.py
MIT
def currency(val, symbol=True, grouping=False, international=False): """Formats val according to the currency settings in the current locale.""" conv = localeconv() # check for illegal values digits = conv[international and 'int_frac_digits' or 'frac_digits'] if digits == 127: raise Val...
Formats val according to the currency settings in the current locale.
currency
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/locale.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/locale.py
MIT
def atof(string, func=float): "Parses a string as a float according to the locale settings." #First, get rid of the grouping ts = localeconv()['thousands_sep'] if ts: string = string.replace(ts, '') #next, replace the decimal point with a dot dd = localeconv()['decimal_point'] if dd:...
Parses a string as a float according to the locale settings.
atof
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/locale.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/locale.py
MIT
def atoi(str): "Converts a string to an integer according to the locale settings." return atof(str, int)
Converts a string to an integer according to the locale settings.
atoi
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/locale.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/locale.py
MIT
def normalize(localename): """ Returns a normalized locale code for the given locale name. The returned locale code is formatted for use with setlocale(). If normalization fails, the original name is returned unchanged. If the given encoding is not known, the func...
Returns a normalized locale code for the given locale name. The returned locale code is formatted for use with setlocale(). If normalization fails, the original name is returned unchanged. If the given encoding is not known, the function defaults to the defaul...
normalize
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/locale.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/locale.py
MIT
def _parse_localename(localename): """ Parses the locale code for localename and returns the result as tuple (language code, encoding). The localename is normalized and passed through the locale alias engine. A ValueError is raised in case the locale name cannot be parsed. ...
Parses the locale code for localename and returns the result as tuple (language code, encoding). The localename is normalized and passed through the locale alias engine. A ValueError is raised in case the locale name cannot be parsed. The language code corresponds to RFC 1766....
_parse_localename
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/locale.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/locale.py
MIT
def _build_localename(localetuple): """ Builds a locale code from the given tuple (language code, encoding). No aliasing or normalizing takes place. """ language, encoding = localetuple if language is None: language = 'C' if encoding is None: return language el...
Builds a locale code from the given tuple (language code, encoding). No aliasing or normalizing takes place.
_build_localename
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/locale.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/locale.py
MIT
def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')): """ Tries to determine the default locale settings and returns them as tuple (language code, encoding). According to POSIX, a program which has not called setlocale(LC_ALL, "") runs using the portable 'C' locale. ...
Tries to determine the default locale settings and returns them as tuple (language code, encoding). According to POSIX, a program which has not called setlocale(LC_ALL, "") runs using the portable 'C' locale. Calling setlocale(LC_ALL, "") lets it use the default locale as defin...
getdefaultlocale
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/locale.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/locale.py
MIT
def getlocale(category=LC_CTYPE): """ Returns the current setting for the given locale category as tuple (language code, encoding). category may be one of the LC_* value except LC_ALL. It defaults to LC_CTYPE. Except for the code 'C', the language code corresponds to RFC 1...
Returns the current setting for the given locale category as tuple (language code, encoding). category may be one of the LC_* value except LC_ALL. It defaults to LC_CTYPE. Except for the code 'C', the language code corresponds to RFC 1766. code and encoding can be None in cas...
getlocale
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/locale.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/locale.py
MIT
def setlocale(category, locale=None): """ Set the locale for the given category. The locale can be a string, an iterable of two strings (language code and encoding), or None. Iterables are converted to strings using the locale aliasing engine. Locale strings are passed directly t...
Set the locale for the given category. The locale can be a string, an iterable of two strings (language code and encoding), or None. Iterables are converted to strings using the locale aliasing engine. Locale strings are passed directly to the C lib. category may be given as...
setlocale
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/locale.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/locale.py
MIT
def getpreferredencoding(do_setlocale = True): """Return the charset that the user is likely using, according to the system configuration.""" if do_setlocale: oldloc = setlocale(LC_CTYPE) try: setlocale(LC_CTYPE, "") ...
Return the charset that the user is likely using, according to the system configuration.
getpreferredencoding
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/locale.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/locale.py
MIT
def split(s): """Split a pathname into two parts: the directory leading up to the final bit, and the basename (the filename, without colons, in that directory). The result (s, t) is such that join(s, t) yields the original argument.""" if ':' not in s: return '', s colon = 0 for i in range(len(...
Split a pathname into two parts: the directory leading up to the final bit, and the basename (the filename, without colons, in that directory). The result (s, t) is such that join(s, t) yields the original argument.
split
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/macpath.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/macpath.py
MIT
def islink(s): """Return true if the pathname refers to a symbolic link.""" try: import Carbon.File return Carbon.File.ResolveAliasFile(s, 0)[2] except: return False
Return true if the pathname refers to a symbolic link.
islink
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/macpath.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/macpath.py
MIT
def lexists(path): """Test whether a path exists. Returns True for broken symbolic links""" try: st = os.lstat(path) except os.error: return False return True
Test whether a path exists. Returns True for broken symbolic links
lexists
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/macpath.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/macpath.py
MIT
def normpath(s): """Normalize a pathname. Will return the same result for equivalent paths.""" if ":" not in s: return ":"+s comps = s.split(":") i = 1 while i < len(comps)-1: if comps[i] == "" and comps[i-1] != "": if i > 1: del comps[i-1:i+1] ...
Normalize a pathname. Will return the same result for equivalent paths.
normpath
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/macpath.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/macpath.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/macpath.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/macpath.py
MIT
def url2pathname(pathname): """OS-specific conversion from a relative URL of the 'file' scheme to a file system path; not recommended for general use.""" # # XXXX The .. handling should be fixed... # tp = urllib.splittype(pathname)[0] if tp and tp != 'file': raise RuntimeError, 'Cann...
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/macurl2path.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/macurl2path.py
MIT
def pathname2url(pathname): """OS-specific conversion from a file system path to a relative URL of the 'file' scheme; not recommended for general use.""" if '/' in pathname: raise RuntimeError, "Cannot convert pathname containing slashes" components = pathname.split(':') # Remove empty first...
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/macurl2path.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/macurl2path.py
MIT
def discard(self, key): """If the keyed message exists, remove it.""" try: self.remove(key) except KeyError: pass
If the keyed message exists, remove it.
discard
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def get(self, key, default=None): """Return the keyed message, or default if it doesn't exist.""" try: return self.__getitem__(key) except KeyError: return default
Return the keyed message, or default if it doesn't exist.
get
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def __getitem__(self, key): """Return the keyed message; raise KeyError if it doesn't exist.""" if not self._factory: return self.get_message(key) else: return self._factory(self.get_file(key))
Return the keyed message; raise KeyError if it doesn't exist.
__getitem__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def itervalues(self): """Return an iterator over all messages.""" for key in self.iterkeys(): try: value = self[key] except KeyError: continue yield value
Return an iterator over all messages.
itervalues
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def iteritems(self): """Return an iterator over (key, message) tuples.""" for key in self.iterkeys(): try: value = self[key] except KeyError: continue yield (key, value)
Return an iterator over (key, message) tuples.
iteritems
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def pop(self, key, default=None): """Delete the keyed message and return it, or default.""" try: result = self[key] except KeyError: return default self.discard(key) return result
Delete the keyed message and return it, or default.
pop
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def popitem(self): """Delete an arbitrary (key, message) pair and return it.""" for key in self.iterkeys(): return (key, self.pop(key)) # This is only run once. else: raise KeyError('No messages in mailbox')
Delete an arbitrary (key, message) pair and return it.
popitem
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def update(self, arg=None): """Change the messages that correspond to certain keys.""" if hasattr(arg, 'iteritems'): source = arg.iteritems() elif hasattr(arg, 'items'): source = arg.items() else: source = arg bad_key = False for key, m...
Change the messages that correspond to certain keys.
update
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _dump_message(self, message, target, mangle_from_=False): # Most files are opened in binary mode to allow predictable seeking. # To get native line endings on disk, the user-friendly \n line endings # used in strings and by email.Message are translated here. """Dump message contents ...
Dump message contents to target file.
_dump_message
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def add(self, message): """Add message and return assigned key.""" tmp_file = self._create_tmp() try: self._dump_message(message, tmp_file) except BaseException: tmp_file.close() os.remove(tmp_file.name) raise _sync_close(tmp_file) ...
Add message and return assigned key.
add
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def discard(self, key): """If the keyed message exists, remove it.""" # This overrides an inapplicable implementation in the superclass. try: self.remove(key) except KeyError: pass except OSError, e: if e.errno != errno.ENOENT: ...
If the keyed message exists, remove it.
discard
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def __setitem__(self, key, message): """Replace the keyed message; raise KeyError if it doesn't exist.""" old_subpath = self._lookup(key) temp_key = self.add(message) temp_subpath = self._lookup(temp_key) if isinstance(message, MaildirMessage): # temp's subdir and suf...
Replace the keyed message; raise KeyError if it doesn't exist.
__setitem__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def get_message(self, key): """Return a Message representation or raise a KeyError.""" subpath = self._lookup(key) f = open(os.path.join(self._path, subpath), 'r') try: if self._factory: msg = self._factory(f) else: msg = MaildirMes...
Return a Message representation or raise a KeyError.
get_message
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def get_string(self, key): """Return a string representation or raise a KeyError.""" f = open(os.path.join(self._path, self._lookup(key)), 'r') try: return f.read() finally: f.close()
Return a string representation or raise a KeyError.
get_string
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def has_key(self, key): """Return True if the keyed message exists, False otherwise.""" self._refresh() return key in self._toc
Return True if the keyed message exists, False otherwise.
has_key
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def flush(self): """Write any pending changes to disk.""" # Maildir changes are always written immediately, so there's nothing # to do. pass
Write any pending changes to disk.
flush
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def add_folder(self, folder): """Create a folder and return a Maildir instance representing it.""" path = os.path.join(self._path, '.' + folder) result = Maildir(path, factory=self._factory) maildirfolder_path = os.path.join(path, 'maildirfolder') if not os.path.exists(maildirfol...
Create a folder and return a Maildir instance representing it.
add_folder
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def remove_folder(self, folder): """Delete the named folder, which must be empty.""" path = os.path.join(self._path, '.' + folder) for entry in os.listdir(os.path.join(path, 'new')) + \ os.listdir(os.path.join(path, 'cur')): if len(entry) < 1 or entry[0] != '.': ...
Delete the named folder, which must be empty.
remove_folder
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _create_tmp(self): """Create a file in the tmp subdirectory and open and return it.""" now = time.time() hostname = socket.gethostname() if '/' in hostname: hostname = hostname.replace('/', r'\057') if ':' in hostname: hostname = hostname.replace(':', ...
Create a file in the tmp subdirectory and open and return it.
_create_tmp
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _lookup(self, key): """Use TOC to return subpath for given key, or raise a KeyError.""" try: if os.path.exists(os.path.join(self._path, self._toc[key])): return self._toc[key] except KeyError: pass self._refresh() try: retur...
Use TOC to return subpath for given key, or raise a KeyError.
_lookup
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def next(self): """Return the next message in a one-time iteration.""" if not hasattr(self, '_onetime_keys'): self._onetime_keys = self.iterkeys() while True: try: return self[self._onetime_keys.next()] except StopIteration: ret...
Return the next message in a one-time iteration.
next
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def add(self, message): """Add message and return assigned key.""" self._lookup() self._toc[self._next_key] = self._append_message(message) self._next_key += 1 # _append_message appends the message to the mailbox file. We # don't need a full rewrite + rename, sync is enou...
Add message and return assigned key.
add
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def remove(self, key): """Remove the keyed message; raise KeyError if it doesn't exist.""" self._lookup(key) del self._toc[key] self._pending = True
Remove the keyed message; raise KeyError if it doesn't exist.
remove
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def __setitem__(self, key, message): """Replace the keyed message; raise KeyError if it doesn't exist.""" self._lookup(key) self._toc[key] = self._append_message(message) self._pending = True
Replace the keyed message; raise KeyError if it doesn't exist.
__setitem__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def has_key(self, key): """Return True if the keyed message exists, False otherwise.""" self._lookup() return key in self._toc
Return True if the keyed message exists, False otherwise.
has_key
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def unlock(self): """Unlock the mailbox if it is locked.""" if self._locked: _unlock_file(self._file) self._locked = False
Unlock the mailbox if it is locked.
unlock
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def flush(self): """Write any pending changes to disk.""" if not self._pending: if self._pending_sync: # Messages have only been added, so syncing the file # is enough. _sync_flush(self._file) self._pending_sync = False ...
Write any pending changes to disk.
flush
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _lookup(self, key=None): """Return (start, stop) or raise KeyError.""" if self._toc is None: self._generate_toc() if key is not None: try: return self._toc[key] except KeyError: raise KeyError('No message with key: %s' % key...
Return (start, stop) or raise KeyError.
_lookup
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _append_message(self, message): """Append message to mailbox and return (start, stop) offsets.""" self._file.seek(0, 2) before = self._file.tell() if len(self._toc) == 0 and not self._pending: # This is the first message, and the _pre_mailbox_hook # hasn't yet...
Append message to mailbox and return (start, stop) offsets.
_append_message
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def get_message(self, key): """Return a Message representation or raise a KeyError.""" start, stop = self._lookup(key) self._file.seek(start) from_line = self._file.readline().replace(os.linesep, '') string = self._file.read(stop - self._file.tell()) msg = self._message_f...
Return a Message representation or raise a KeyError.
get_message
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def get_string(self, key, from_=False): """Return a string representation or raise a KeyError.""" start, stop = self._lookup(key) self._file.seek(start) if not from_: self._file.readline() string = self._file.read(stop - self._file.tell()) return string.replac...
Return a string representation or raise a KeyError.
get_string
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def get_file(self, key, from_=False): """Return a file-like representation or raise a KeyError.""" start, stop = self._lookup(key) self._file.seek(start) if not from_: self._file.readline() return _PartialFile(self._file, self._file.tell(), stop)
Return a file-like representation or raise a KeyError.
get_file
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _install_message(self, message): """Format a message and blindly write to self._file.""" from_line = None if isinstance(message, str) and message.startswith('From '): newline = message.find('\n') if newline != -1: from_line = message[:newline] ...
Format a message and blindly write to self._file.
_install_message
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _generate_toc(self): """Generate key-to-(start, stop) table of contents.""" starts, stops = [], [] last_was_empty = False self._file.seek(0) while True: line_pos = self._file.tell() line = self._file.readline() if line.startswith('From '): ...
Generate key-to-(start, stop) table of contents.
_generate_toc
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _generate_toc(self): """Generate key-to-(start, stop) table of contents.""" starts, stops = [], [] self._file.seek(0) next_pos = 0 while True: line_pos = next_pos line = self._file.readline() next_pos = self._file.tell() if line...
Generate key-to-(start, stop) table of contents.
_generate_toc
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def add(self, message): """Add message and return assigned key.""" keys = self.keys() if len(keys) == 0: new_key = 1 else: new_key = max(keys) + 1 new_path = os.path.join(self._path, str(new_key)) f = _create_carefully(new_path) closed = Fa...
Add message and return assigned key.
add
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def remove(self, key): """Remove the keyed message; raise KeyError if it doesn't exist.""" path = os.path.join(self._path, str(key)) try: f = open(path, 'rb+') except IOError, e: if e.errno == errno.ENOENT: raise KeyError('No message with key: %s' ...
Remove the keyed message; raise KeyError if it doesn't exist.
remove
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def __setitem__(self, key, message): """Replace the keyed message; raise KeyError if it doesn't exist.""" path = os.path.join(self._path, str(key)) try: f = open(path, 'rb+') except IOError, e: if e.errno == errno.ENOENT: raise KeyError('No message...
Replace the keyed message; raise KeyError if it doesn't exist.
__setitem__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def get_message(self, key): """Return a Message representation or raise a KeyError.""" try: if self._locked: f = open(os.path.join(self._path, str(key)), 'r+') else: f = open(os.path.join(self._path, str(key)), 'r') except IOError, e: ...
Return a Message representation or raise a KeyError.
get_message
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def get_string(self, key): """Return a string representation or raise a KeyError.""" try: if self._locked: f = open(os.path.join(self._path, str(key)), 'r+') else: f = open(os.path.join(self._path, str(key)), 'r') except IOError, e: ...
Return a string representation or raise a KeyError.
get_string
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def get_file(self, key): """Return a file-like representation or raise a KeyError.""" try: f = open(os.path.join(self._path, str(key)), 'rb') except IOError, e: if e.errno == errno.ENOENT: raise KeyError('No message with key: %s' % key) else: ...
Return a file-like representation or raise a KeyError.
get_file
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def unlock(self): """Unlock the mailbox if it is locked.""" if self._locked: _unlock_file(self._file) _sync_close(self._file) del self._file self._locked = False
Unlock the mailbox if it is locked.
unlock
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def remove_folder(self, folder): """Delete the named folder, which must be empty.""" path = os.path.join(self._path, folder) entries = os.listdir(path) if entries == ['.mh_sequences']: os.remove(os.path.join(path, '.mh_sequences')) elif entries == []: pass...
Delete the named folder, which must be empty.
remove_folder
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def get_sequences(self): """Return a name-to-key-list dictionary to define each sequence.""" results = {} f = open(os.path.join(self._path, '.mh_sequences'), 'r') try: all_keys = set(self.keys()) for line in f: try: name, conten...
Return a name-to-key-list dictionary to define each sequence.
get_sequences
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def set_sequences(self, sequences): """Set sequences using the given name-to-key-list dictionary.""" f = open(os.path.join(self._path, '.mh_sequences'), 'r+') try: os.close(os.open(f.name, os.O_WRONLY | os.O_TRUNC)) for name, keys in sequences.iteritems(): ...
Set sequences using the given name-to-key-list dictionary.
set_sequences
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def pack(self): """Re-name messages to eliminate numbering gaps. Invalidates keys.""" sequences = self.get_sequences() prev = 0 changes = [] for key in self.iterkeys(): if key - 1 != prev: changes.append((key, prev + 1)) if hasattr(os, ...
Re-name messages to eliminate numbering gaps. Invalidates keys.
pack
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _dump_sequences(self, message, key): """Inspect a new MHMessage and update sequences appropriately.""" pending_sequences = message.get_sequences() all_sequences = self.get_sequences() for name, key_list in all_sequences.iteritems(): if name in pending_sequences: ...
Inspect a new MHMessage and update sequences appropriately.
_dump_sequences
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def add(self, message): """Add message and return assigned key.""" key = _singlefileMailbox.add(self, message) if isinstance(message, BabylMessage): self._labels[key] = message.get_labels() return key
Add message and return assigned key.
add
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def remove(self, key): """Remove the keyed message; raise KeyError if it doesn't exist.""" _singlefileMailbox.remove(self, key) if key in self._labels: del self._labels[key]
Remove the keyed message; raise KeyError if it doesn't exist.
remove
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def __setitem__(self, key, message): """Replace the keyed message; raise KeyError if it doesn't exist.""" _singlefileMailbox.__setitem__(self, key, message) if isinstance(message, BabylMessage): self._labels[key] = message.get_labels()
Replace the keyed message; raise KeyError if it doesn't exist.
__setitem__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def get_message(self, key): """Return a Message representation or raise a KeyError.""" start, stop = self._lookup(key) self._file.seek(start) self._file.readline() # Skip '1,' line specifying labels. original_headers = StringIO.StringIO() while True: line = ...
Return a Message representation or raise a KeyError.
get_message
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def get_string(self, key): """Return a string representation or raise a KeyError.""" start, stop = self._lookup(key) self._file.seek(start) self._file.readline() # Skip '1,' line specifying labels. original_headers = StringIO.StringIO() while True: line = se...
Return a string representation or raise a KeyError.
get_string
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def get_labels(self): """Return a list of user-defined labels in the mailbox.""" self._lookup() labels = set() for label_list in self._labels.values(): labels.update(label_list) labels.difference_update(self._special_labels) return list(labels)
Return a list of user-defined labels in the mailbox.
get_labels
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _generate_toc(self): """Generate key-to-(start, stop) table of contents.""" starts, stops = [], [] self._file.seek(0) next_pos = 0 label_lists = [] while True: line_pos = next_pos line = self._file.readline() next_pos = self._file.t...
Generate key-to-(start, stop) table of contents.
_generate_toc
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _pre_mailbox_hook(self, f): """Called before writing the mailbox to file f.""" f.write('BABYL OPTIONS:%sVersion: 5%sLabels:%s%s\037' % (os.linesep, os.linesep, ','.join(self.get_labels()), os.linesep))
Called before writing the mailbox to file f.
_pre_mailbox_hook
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _install_message(self, message): """Write message contents and return (start, stop).""" start = self._file.tell() if isinstance(message, BabylMessage): special_labels = [] labels = [] for label in message.get_labels(): if label in self._spe...
Write message contents and return (start, stop).
_install_message
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _become_message(self, message): """Assume the non-format-specific state of message.""" for name in ('_headers', '_unixfrom', '_payload', '_charset', 'preamble', 'epilogue', 'defects', '_default_type'): self.__dict__[name] = message.__dict__[name]
Assume the non-format-specific state of message.
_become_message
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _explain_to(self, message): """Copy format-specific state to message insofar as possible.""" if isinstance(message, Message): return # There's nothing format-specific to explain. else: raise TypeError('Cannot convert to specified type')
Copy format-specific state to message insofar as possible.
_explain_to
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def set_subdir(self, subdir): """Set subdir to 'new' or 'cur'.""" if subdir == 'new' or subdir == 'cur': self._subdir = subdir else: raise ValueError("subdir must be 'new' or 'cur': %s" % subdir)
Set subdir to 'new' or 'cur'.
set_subdir
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def get_flags(self): """Return as a string the flags that are set.""" if self._info.startswith('2,'): return self._info[2:] else: return ''
Return as a string the flags that are set.
get_flags
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def remove_flag(self, flag): """Unset the given string flag(s) without changing others.""" if self.get_flags() != '': self.set_flags(''.join(set(self.get_flags()) - set(flag)))
Unset the given string flag(s) without changing others.
remove_flag
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def set_date(self, date): """Set delivery date of message, in seconds since the epoch.""" try: self._date = float(date) except ValueError: raise TypeError("can't convert to float: %s" % date)
Set delivery date of message, in seconds since the epoch.
set_date
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _explain_to(self, message): """Copy Maildir-specific state to message insofar as possible.""" if isinstance(message, MaildirMessage): message.set_flags(self.get_flags()) message.set_subdir(self.get_subdir()) message.set_date(self.get_date()) elif isinstanc...
Copy Maildir-specific state to message insofar as possible.
_explain_to
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def set_from(self, from_, time_=None): """Set "From " line, formatting and appending time_ if specified.""" if time_ is not None: if time_ is True: time_ = time.gmtime() from_ += ' ' + time.asctime(time_) self._from = from_
Set "From " line, formatting and appending time_ if specified.
set_from
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def set_flags(self, flags): """Set the given flags and unset all others.""" flags = set(flags) status_flags, xstatus_flags = '', '' for flag in ('R', 'O'): if flag in flags: status_flags += flag flags.remove(flag) for flag in ('D', 'F',...
Set the given flags and unset all others.
set_flags
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def remove_flag(self, flag): """Unset the given string flag(s) without changing others.""" if 'Status' in self or 'X-Status' in self: self.set_flags(''.join(set(self.get_flags()) - set(flag)))
Unset the given string flag(s) without changing others.
remove_flag
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _explain_to(self, message): """Copy mbox- or MMDF-specific state to message insofar as possible.""" if isinstance(message, MaildirMessage): flags = set(self.get_flags()) if 'O' in flags: message.set_subdir('cur') if 'F' in flags: me...
Copy mbox- or MMDF-specific state to message insofar as possible.
_explain_to
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def add_sequence(self, sequence): """Add sequence to list of sequences including the message.""" if isinstance(sequence, str): if not sequence in self._sequences: self._sequences.append(sequence) else: raise TypeError('sequence must be a string: %s' % type...
Add sequence to list of sequences including the message.
add_sequence
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def remove_sequence(self, sequence): """Remove sequence from the list of sequences including the message.""" try: self._sequences.remove(sequence) except ValueError: pass
Remove sequence from the list of sequences including the message.
remove_sequence
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _explain_to(self, message): """Copy MH-specific state to message insofar as possible.""" if isinstance(message, MaildirMessage): sequences = set(self.get_sequences()) if 'unseen' in sequences: message.set_subdir('cur') else: message...
Copy MH-specific state to message insofar as possible.
_explain_to
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def add_label(self, label): """Add label to list of labels on the message.""" if isinstance(label, str): if label not in self._labels: self._labels.append(label) else: raise TypeError('label must be a string: %s' % type(label))
Add label to list of labels on the message.
add_label
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def remove_label(self, label): """Remove label from the list of labels on the message.""" try: self._labels.remove(label) except ValueError: pass
Remove label from the list of labels on the message.
remove_label
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def update_visible(self): """Update and/or sensibly generate a set of visible headers.""" for header in self._visible.keys(): if header in self: self._visible.replace_header(header, self[header]) else: del self._visible[header] for header i...
Update and/or sensibly generate a set of visible headers.
update_visible
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _explain_to(self, message): """Copy Babyl-specific state to message insofar as possible.""" if isinstance(message, MaildirMessage): labels = set(self.get_labels()) if 'unseen' in labels: message.set_subdir('cur') else: message.set_s...
Copy Babyl-specific state to message insofar as possible.
_explain_to
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def seek(self, offset, whence=0): """Change position, possibly with respect to start or stop.""" if whence == 0: self._pos = self._start whence = 1 elif whence == 2: self._pos = self._stop whence = 1 _ProxyFile.seek(self, offset, whence)
Change position, possibly with respect to start or stop.
seek
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _read(self, size, read_method): """Read size bytes using read_method, honoring start and stop.""" remaining = self._stop - self._pos if remaining <= 0: return '' if size is None or size < 0 or size > remaining: size = remaining return _ProxyFile._read(...
Read size bytes using read_method, honoring start and stop.
_read
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _lock_file(f, dotlock=True): """Lock file f using lockf and dot locking.""" dotlock_done = False try: if fcntl: try: fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError, e: if e.errno in (errno.EAGAIN, errno.EACCES, errno.EROFS): ...
Lock file f using lockf and dot locking.
_lock_file
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _unlock_file(f): """Unlock file f using lockf and dot locking.""" if fcntl: fcntl.lockf(f, fcntl.LOCK_UN) if os.path.exists(f.name + '.lock'): os.remove(f.name + '.lock')
Unlock file f using lockf and dot locking.
_unlock_file
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _create_carefully(path): """Create a file if it doesn't exist and open for reading and writing.""" fd = os.open(path, os.O_CREAT | os.O_EXCL | os.O_RDWR, 0666) try: return open(path, 'rb+') finally: os.close(fd)
Create a file if it doesn't exist and open for reading and writing.
_create_carefully
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT
def _sync_flush(f): """Ensure changes to file f are physically on disk.""" f.flush() if hasattr(os, 'fsync'): os.fsync(f.fileno())
Ensure changes to file f are physically on disk.
_sync_flush
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/mailbox.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/mailbox.py
MIT