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 __init__(self, type=None, content=None, name=None): """ Initializer. Takes optional type, content, and name. The type, if given must be a token type (< 256). If not given, this matches any *leaf* node; the content may still be required. The content, if given, must be a st...
Initializer. Takes optional type, content, and name. The type, if given must be a token type (< 256). If not given, this matches any *leaf* node; the content may still be required. The content, if given, must be a string. If a name is given, the matching node is stored in t...
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pytree.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pytree.py
MIT
def match(self, node, results=None): """Override match() to insist on a leaf node.""" if not isinstance(node, Leaf): return False return BasePattern.match(self, node, results)
Override match() to insist on a leaf node.
match
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pytree.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pytree.py
MIT
def __init__(self, type=None, content=None, name=None): """ Initializer. Takes optional type, content, and name. The type, if given, must be a symbol type (>= 256). If the type is None this matches *any* single node (leaf or not), except if content is not None, in which it onl...
Initializer. Takes optional type, content, and name. The type, if given, must be a symbol type (>= 256). If the type is None this matches *any* single node (leaf or not), except if content is not None, in which it only matches non-leaf nodes that also match the content patter...
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pytree.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pytree.py
MIT
def _submatch(self, node, results=None): """ Match the pattern's content to the node's children. This assumes the node type matches and self.content is not None. Returns True if it matches, False if not. If results is not None, it must be a dict which will be updated w...
Match the pattern's content to the node's children. This assumes the node type matches and self.content is not None. Returns True if it matches, False if not. If results is not None, it must be a dict which will be updated with the nodes matching named subpatterns. W...
_submatch
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pytree.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pytree.py
MIT
def __init__(self, content=None, min=0, max=HUGE, name=None): """ Initializer. Args: content: optional sequence of subsequences of patterns; if absent, matches one node; if present, each subsequence is an alternative [*] min: opt...
Initializer. Args: content: optional sequence of subsequences of patterns; if absent, matches one node; if present, each subsequence is an alternative [*] min: optional minimum number of times to match, default 0 max: option...
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pytree.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pytree.py
MIT
def match_seq(self, nodes, results=None): """Does this pattern exactly match a sequence of nodes?""" for c, r in self.generate_matches(nodes): if c == len(nodes): if results is not None: results.update(r) if self.name: ...
Does this pattern exactly match a sequence of nodes?
match_seq
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pytree.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pytree.py
MIT
def generate_matches(self, nodes): """ Generator yielding matches for a sequence of nodes. Args: nodes: sequence of nodes Yields: (count, results) tuples where: count: the match comprises nodes[:count]; results: dict containing named subm...
Generator yielding matches for a sequence of nodes. Args: nodes: sequence of nodes Yields: (count, results) tuples where: count: the match comprises nodes[:count]; results: dict containing named submatches.
generate_matches
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pytree.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pytree.py
MIT
def _iterative_matches(self, nodes): """Helper to iteratively yield the matches.""" nodelen = len(nodes) if 0 >= self.min: yield 0, {} results = [] # generate matches that use just one alt from self.content for alt in self.content: for c, r in gen...
Helper to iteratively yield the matches.
_iterative_matches
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pytree.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pytree.py
MIT
def _recursive_matches(self, nodes, count): """Helper to recursively yield the matches.""" assert self.content is not None if count >= self.min: yield 0, {} if count < self.max: for alt in self.content: for c0, r0 in generate_matches(alt, nodes): ...
Helper to recursively yield the matches.
_recursive_matches
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pytree.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pytree.py
MIT
def __init__(self, content=None): """ Initializer. The argument is either a pattern or None. If it is None, this only matches an empty sequence (effectively '$' in regex lingo). If it is not None, this matches whenever the argument pattern doesn't have any matches. ...
Initializer. The argument is either a pattern or None. If it is None, this only matches an empty sequence (effectively '$' in regex lingo). If it is not None, this matches whenever the argument pattern doesn't have any matches.
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pytree.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pytree.py
MIT
def generate_matches(patterns, nodes): """ Generator yielding matches for a sequence of patterns and nodes. Args: patterns: a sequence of patterns nodes: a sequence of nodes Yields: (count, results) tuples where: count: the entire sequence of patterns matches nodes[:cou...
Generator yielding matches for a sequence of patterns and nodes. Args: patterns: a sequence of patterns nodes: a sequence of nodes Yields: (count, results) tuples where: count: the entire sequence of patterns matches nodes[:count]; results: dict containing named su...
generate_matches
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pytree.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pytree.py
MIT
def get_all_fix_names(fixer_pkg, remove_prefix=True): """Return a sorted list of all available fix names in the given package.""" pkg = __import__(fixer_pkg, [], [], ["*"]) fixer_dir = os.path.dirname(pkg.__file__) fix_names = [] for name in sorted(os.listdir(fixer_dir)): if name.startswith(...
Return a sorted list of all available fix names in the given package.
get_all_fix_names
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def _get_head_types(pat): """ Accepts a pytree Pattern Node and returns a set of the pattern types which will match first. """ if isinstance(pat, (pytree.NodePattern, pytree.LeafPattern)): # NodePatters must either have no type and no content # or a type and content -- so they don't g...
Accepts a pytree Pattern Node and returns a set of the pattern types which will match first.
_get_head_types
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def _get_headnode_dict(fixer_list): """ Accepts a list of fixers and returns a dictionary of head node type --> fixer list. """ head_nodes = collections.defaultdict(list) every = [] for fixer in fixer_list: if fixer.pattern: try: heads = _get_head_types(fixer...
Accepts a list of fixers and returns a dictionary of head node type --> fixer list.
_get_headnode_dict
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def get_fixers_from_package(pkg_name): """ Return the fully qualified names for fixers in the package pkg_name. """ return [pkg_name + "." + fix_name for fix_name in get_all_fix_names(pkg_name, False)]
Return the fully qualified names for fixers in the package pkg_name.
get_fixers_from_package
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def __init__(self, fixer_names, options=None, explicit=None): """Initializer. Args: fixer_names: a list of fixers to import options: a dict with configuration. explicit: a list of fixers to run even if they are explicit. """ self.fixers = fixer_names ...
Initializer. Args: fixer_names: a list of fixers to import options: a dict with configuration. explicit: a list of fixers to run even if they are explicit.
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def get_fixers(self): """Inspects the options to load the requested patterns and handlers. Returns: (pre_order, post_order), where pre_order is the list of fixers that want a pre-order AST traversal, and post_order is the list that want post-order traversal. """ ...
Inspects the options to load the requested patterns and handlers. Returns: (pre_order, post_order), where pre_order is the list of fixers that want a pre-order AST traversal, and post_order is the list that want post-order traversal.
get_fixers
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def refactor(self, items, write=False, doctests_only=False): """Refactor a list of files and directories.""" for dir_or_file in items: if os.path.isdir(dir_or_file): self.refactor_dir(dir_or_file, write, doctests_only) else: self.refactor_file(dir...
Refactor a list of files and directories.
refactor
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def refactor_dir(self, dir_name, write=False, doctests_only=False): """Descends down a directory and refactor every Python file found. Python files are assumed to have a .py extension. Files and subdirectories starting with '.' are skipped. """ py_ext = os.extsep + "py" ...
Descends down a directory and refactor every Python file found. Python files are assumed to have a .py extension. Files and subdirectories starting with '.' are skipped.
refactor_dir
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def _read_python_source(self, filename): """ Do our best to decode a Python source file correctly. """ try: f = open(filename, "rb") except IOError as err: self.log_error("Can't open %s: %s", filename, err) return None, None try: ...
Do our best to decode a Python source file correctly.
_read_python_source
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def refactor_string(self, data, name): """Refactor a given input string. Args: data: a string holding the code to be refactored. name: a human-readable name for use in error/log messages. Returns: An AST corresponding to the refactored input stream; None if ...
Refactor a given input string. Args: data: a string holding the code to be refactored. name: a human-readable name for use in error/log messages. Returns: An AST corresponding to the refactored input stream; None if there were errors during the parse. ...
refactor_string
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def refactor_tree(self, tree, name): """Refactors a parse tree (modifying the tree in place). For compatible patterns the bottom matcher module is used. Otherwise the tree is traversed node-to-node for matches. Args: tree: a pytree.Node instance representing the roo...
Refactors a parse tree (modifying the tree in place). For compatible patterns the bottom matcher module is used. Otherwise the tree is traversed node-to-node for matches. Args: tree: a pytree.Node instance representing the root of the tree to be refactored...
refactor_tree
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def traverse_by(self, fixers, traversal): """Traverse an AST, applying a set of fixers to each node. This is a helper method for refactor_tree(). Args: fixers: a list of fixer instances. traversal: a generator that yields AST nodes. Returns: None ...
Traverse an AST, applying a set of fixers to each node. This is a helper method for refactor_tree(). Args: fixers: a list of fixer instances. traversal: a generator that yields AST nodes. Returns: None
traverse_by
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def processed_file(self, new_text, filename, old_text=None, write=False, encoding=None): """ Called when a file has been refactored and there may be changes. """ self.files.append(filename) if old_text is None: old_text = self._read_python_sourc...
Called when a file has been refactored and there may be changes.
processed_file
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def write_file(self, new_text, filename, old_text, encoding=None): """Writes a string to a file. It first shows a unified diff between the old text and the new text, and then rewrites the file; the latter is only done if the write option is set. """ try: f = ...
Writes a string to a file. It first shows a unified diff between the old text and the new text, and then rewrites the file; the latter is only done if the write option is set.
write_file
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def refactor_docstring(self, input, filename): """Refactors a docstring, looking for doctests. This returns a modified version of the input string. It looks for doctests, which start with a ">>>" prompt, and may be continued with "..." prompts, as long as the "..." is indented ...
Refactors a docstring, looking for doctests. This returns a modified version of the input string. It looks for doctests, which start with a ">>>" prompt, and may be continued with "..." prompts, as long as the "..." is indented the same as the ">>>". (Unfortunately we can't us...
refactor_docstring
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def refactor_doctest(self, block, lineno, indent, filename): """Refactors one doctest. A doctest is given as a block of lines, the first of which starts with ">>>" (possibly indented), while the remaining lines start with "..." (identically indented). """ try: ...
Refactors one doctest. A doctest is given as a block of lines, the first of which starts with ">>>" (possibly indented), while the remaining lines start with "..." (identically indented).
refactor_doctest
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def parse_block(self, block, lineno, indent): """Parses a block into a tree. This is necessary to get correct line number / offset information in the parser diagnostics and embedded into the parse tree. """ tree = self.driver.parse_tokens(self.wrap_toks(block, lineno, indent)) ...
Parses a block into a tree. This is necessary to get correct line number / offset information in the parser diagnostics and embedded into the parse tree.
parse_block
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def wrap_toks(self, block, lineno, indent): """Wraps a tokenize stream to systematically modify start/end.""" tokens = tokenize.generate_tokens(self.gen_lines(block, indent).next) for type, value, (line0, col0), (line1, col1), line_text in tokens: line0 += lineno - 1 line...
Wraps a tokenize stream to systematically modify start/end.
wrap_toks
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def gen_lines(self, block, indent): """Generates lines as expected by tokenize from a list of lines. This strips the first len(indent + self.PS1) characters off each line. """ prefix1 = indent + self.PS1 prefix2 = indent + self.PS2 prefix = prefix1 for line in bl...
Generates lines as expected by tokenize from a list of lines. This strips the first len(indent + self.PS1) characters off each line.
gen_lines
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/refactor.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/refactor.py
MIT
def traverse_imports(names): """ Walks over all the names imported in a dotted_as_names node. """ pending = [names] while pending: node = pending.pop() if node.type == token.NAME: yield node.value elif node.type == syms.dotted_name: yield "".join([ch.v...
Walks over all the names imported in a dotted_as_names node.
traverse_imports
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/fixes/fix_import.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/fixes/fix_import.py
MIT
def has_metaclass(parent): """ we have to check the cls_node without changing it. There are two possibilities: 1) clsdef => suite => simple_stmt => expr_stmt => Leaf('__meta') 2) clsdef => simple_stmt => expr_stmt => Leaf('__meta') """ for node in parent.children: if no...
we have to check the cls_node without changing it. There are two possibilities: 1) clsdef => suite => simple_stmt => expr_stmt => Leaf('__meta') 2) clsdef => simple_stmt => expr_stmt => Leaf('__meta')
has_metaclass
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/fixes/fix_metaclass.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/fixes/fix_metaclass.py
MIT
def fixup_parse_tree(cls_node): """ one-line classes don't get a suite in the parse tree so we add one to normalize the tree """ for node in cls_node.children: if node.type == syms.suite: # already in the preferred format, do nothing return # !%@#! oneliners have...
one-line classes don't get a suite in the parse tree so we add one to normalize the tree
fixup_parse_tree
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/fixes/fix_metaclass.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/fixes/fix_metaclass.py
MIT
def fixup_simple_stmt(parent, i, stmt_node): """ if there is a semi-colon all the parts count as part of the same simple_stmt. We just want the __metaclass__ part so we move everything after the semi-colon into its own simple_stmt node """ for semi_ind, node in enumerate(stmt_node.children)...
if there is a semi-colon all the parts count as part of the same simple_stmt. We just want the __metaclass__ part so we move everything after the semi-colon into its own simple_stmt node
fixup_simple_stmt
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/fixes/fix_metaclass.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/fixes/fix_metaclass.py
MIT
def fixup_indent(suite): """ If an INDENT is followed by a thing with a prefix then nuke the prefix Otherwise we get in trouble when removing __metaclass__ at suite start """ kids = suite.children[::-1] # find the first indent while kids: node = kids.pop() if node.type == tok...
If an INDENT is followed by a thing with a prefix then nuke the prefix Otherwise we get in trouble when removing __metaclass__ at suite start
fixup_indent
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/fixes/fix_metaclass.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/fixes/fix_metaclass.py
MIT
def transform_import(self, node, results): """Transform for the basic import case. Replaces the old import name with a comma separated list of its replacements. """ import_mod = results.get("module") pref = import_mod.prefix names = [] # create a N...
Transform for the basic import case. Replaces the old import name with a comma separated list of its replacements.
transform_import
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/fixes/fix_urllib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/fixes/fix_urllib.py
MIT
def transform_member(self, node, results): """Transform for imports of specific module elements. Replaces the module to be imported from with the appropriate new module. """ mod_member = results.get("mod_member") pref = mod_member.prefix member = results.get...
Transform for imports of specific module elements. Replaces the module to be imported from with the appropriate new module.
transform_member
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/fixes/fix_urllib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/fixes/fix_urllib.py
MIT
def transform_dot(self, node, results): """Transform for calls to module members in code.""" module_dot = results.get("bare_with_attr") member = results.get("member") new_name = None if isinstance(member, list): member = member[0] for change in MAPPING[module_...
Transform for calls to module members in code.
transform_dot
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/fixes/fix_urllib.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/fixes/fix_urllib.py
MIT
def parse_graminit_h(self, filename): """Parse the .h file written by pgen. (Internal) This file is a sequence of #define statements defining the nonterminals of the grammar as numbers. We build two tables mapping the numbers to names and back. """ try: f ...
Parse the .h file written by pgen. (Internal) This file is a sequence of #define statements defining the nonterminals of the grammar as numbers. We build two tables mapping the numbers to names and back.
parse_graminit_h
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/conv.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/conv.py
MIT
def parse_graminit_c(self, filename): """Parse the .c file written by pgen. (Internal) The file looks as follows. The first two lines are always this: #include "pgenheaders.h" #include "grammar.h" After that come four blocks: 1) one or more state definitions ...
Parse the .c file written by pgen. (Internal) The file looks as follows. The first two lines are always this: #include "pgenheaders.h" #include "grammar.h" After that come four blocks: 1) one or more state definitions 2) a table defining dfas 3) a table defi...
parse_graminit_c
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/conv.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/conv.py
MIT
def parse_tokens(self, tokens, debug=False): """Parse a series of tokens and return the syntax tree.""" # XXX Move the prefix computation into a wrapper around tokenize. p = parse.Parser(self.grammar, self.convert) p.setup() lineno = 1 column = 0 type = value = st...
Parse a series of tokens and return the syntax tree.
parse_tokens
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/driver.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/driver.py
MIT
def parse_stream_raw(self, stream, debug=False): """Parse a stream and return the syntax tree.""" tokens = tokenize.generate_tokens(stream.readline) return self.parse_tokens(tokens, debug)
Parse a stream and return the syntax tree.
parse_stream_raw
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/driver.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/driver.py
MIT
def parse_file(self, filename, encoding=None, debug=False): """Parse a file and return the syntax tree.""" stream = codecs.open(filename, "r", encoding) try: return self.parse_stream(stream, debug) finally: stream.close()
Parse a file and return the syntax tree.
parse_file
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/driver.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/driver.py
MIT
def parse_string(self, text, debug=False): """Parse a string and return the syntax tree.""" tokens = tokenize.generate_tokens(StringIO.StringIO(text).readline) return self.parse_tokens(tokens, debug)
Parse a string and return the syntax tree.
parse_string
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/driver.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/driver.py
MIT
def load_grammar(gt="Grammar.txt", gp=None, save=True, force=False, logger=None): """Load the grammar (maybe from a pickle).""" if logger is None: logger = logging.getLogger() if gp is None: head, tail = os.path.splitext(gt) if tail == ".txt": tail = "" ...
Load the grammar (maybe from a pickle).
load_grammar
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/driver.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/driver.py
MIT
def _newer(a, b): """Inquire whether file a was written since file b.""" if not os.path.exists(a): return False if not os.path.exists(b): return True return os.path.getmtime(a) >= os.path.getmtime(b)
Inquire whether file a was written since file b.
_newer
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/driver.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/driver.py
MIT
def main(*args): """Main program, when run as a script: produce grammar pickle files. Calls load_grammar for each argument, a path to a grammar text file. """ if not args: args = sys.argv[1:] logging.basicConfig(level=logging.INFO, stream=sys.stdout, format='%(messag...
Main program, when run as a script: produce grammar pickle files. Calls load_grammar for each argument, a path to a grammar text file.
main
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/driver.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/driver.py
MIT
def dump(self, filename): """Dump the grammar tables to a pickle file.""" f = open(filename, "wb") pickle.dump(self.__dict__, f, 2) f.close()
Dump the grammar tables to a pickle file.
dump
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/grammar.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/grammar.py
MIT
def load(self, filename): """Load the grammar tables from a pickle file.""" f = open(filename, "rb") d = pickle.load(f) f.close() self.__dict__.update(d)
Load the grammar tables from a pickle file.
load
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/grammar.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/grammar.py
MIT
def report(self): """Dump the grammar tables to standard output, for debugging.""" from pprint import pprint print "s2n" pprint(self.symbol2number) print "n2s" pprint(self.number2symbol) print "states" pprint(self.states) print "dfas" pprin...
Dump the grammar tables to standard output, for debugging.
report
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/grammar.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/grammar.py
MIT
def __init__(self, grammar, convert=None): """Constructor. The grammar argument is a grammar.Grammar instance; see the grammar module for more information. The parser is not ready yet for parsing; you must call the setup() method to get it started. The optional convert...
Constructor. The grammar argument is a grammar.Grammar instance; see the grammar module for more information. The parser is not ready yet for parsing; you must call the setup() method to get it started. The optional convert argument is a function mapping concrete synta...
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/parse.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/parse.py
MIT
def setup(self, start=None): """Prepare for parsing. This *must* be called before starting to parse. The optional argument is an alternative start symbol; it defaults to the grammar's start symbol. You can use a Parser instance to parse any number of programs; each tim...
Prepare for parsing. This *must* be called before starting to parse. The optional argument is an alternative start symbol; it defaults to the grammar's start symbol. You can use a Parser instance to parse any number of programs; each time you call setup() the parser is reset t...
setup
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/parse.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/parse.py
MIT
def addtoken(self, type, value, context): """Add a token; return True iff this is the end of the program.""" # Map from token to label ilabel = self.classify(type, value, context) # Loop until the token is shifted; may raise exceptions while True: dfa, state, node = s...
Add a token; return True iff this is the end of the program.
addtoken
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/parse.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/parse.py
MIT
def tokenize(readline, tokeneater=printtoken): """ The tokenize() function accepts two parameters: one representing the input stream, and one providing an output mechanism for tokenize(). The first parameter, readline, must be a callable object which provides the same interface as the readline() me...
The tokenize() function accepts two parameters: one representing the input stream, and one providing an output mechanism for tokenize(). The first parameter, readline, must be a callable object which provides the same interface as the readline() method of built-in file objects. Each call to the fu...
tokenize
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/tokenize.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/tokenize.py
MIT
def detect_encoding(readline): """ The detect_encoding() function is used to detect the encoding that should be used to decode a Python source file. It requires one argument, readline, in the same way as the tokenize() generator. It will call readline a maximum of twice, and return the encoding use...
The detect_encoding() function is used to detect the encoding that should be used to decode a Python source file. It requires one argument, readline, in the same way as the tokenize() generator. It will call readline a maximum of twice, and return the encoding used (as a string) and a list of any ...
detect_encoding
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/tokenize.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/tokenize.py
MIT
def generate_tokens(readline): """ The generate_tokens() generator requires one argument, readline, which must be a callable object which provides the same interface as the readline() method of built-in file objects. Each call to the function should return one line of input as a string. Alternately...
The generate_tokens() generator requires one argument, readline, which must be a callable object which provides the same interface as the readline() method of built-in file objects. Each call to the function should return one line of input as a string. Alternately, readline can be a callable funct...
generate_tokens
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/lib2to3/pgen2/tokenize.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/lib2to3/pgen2/tokenize.py
MIT
def fileConfig(fname, defaults=None, disable_existing_loggers=True): """ Read the logging configuration from a ConfigParser-format file. This can be called several times from an application, allowing an end user the ability to select from various pre-canned configurations (if the developer provides...
Read the logging configuration from a ConfigParser-format file. This can be called several times from an application, allowing an end user the ability to select from various pre-canned configurations (if the developer provides a mechanism to present the choices and load the chosen configuration). ...
fileConfig
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/config.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/config.py
MIT
def _resolve(name): """Resolve a dotted name to a global object.""" name = name.split('.') used = name.pop(0) found = __import__(used) for n in name: used = used + '.' + n try: found = getattr(found, n) except AttributeError: __import__(used) ...
Resolve a dotted name to a global object.
_resolve
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/config.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/config.py
MIT
def resolve(self, s): """ Resolve strings to objects using standard import and attribute syntax. """ name = s.split('.') used = name.pop(0) try: found = self.importer(used) for frag in name: used += '.' + frag ...
Resolve strings to objects using standard import and attribute syntax.
resolve
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/config.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/config.py
MIT
def cfg_convert(self, value): """Default converter for the cfg:// protocol.""" rest = value m = self.WORD_PATTERN.match(rest) if m is None: raise ValueError("Unable to convert %r" % value) else: rest = rest[m.end():] d = self.config[m.groups()[...
Default converter for the cfg:// protocol.
cfg_convert
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/config.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/config.py
MIT
def convert(self, value): """ Convert values to an appropriate type. dicts, lists and tuples are replaced by their converting alternatives. Strings are checked to see if they have a conversion format and are converted if they do. """ if not isinstance(value, ConvertingDic...
Convert values to an appropriate type. dicts, lists and tuples are replaced by their converting alternatives. Strings are checked to see if they have a conversion format and are converted if they do.
convert
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/config.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/config.py
MIT
def configure_custom(self, config): """Configure an object with a user-supplied factory.""" c = config.pop('()') if not hasattr(c, '__call__') and hasattr(types, 'ClassType') and type(c) != types.ClassType: c = self.resolve(c) props = config.pop('.', None) # Check for...
Configure an object with a user-supplied factory.
configure_custom
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/config.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/config.py
MIT
def as_tuple(self, value): """Utility function which converts lists to tuples.""" if isinstance(value, list): value = tuple(value) return value
Utility function which converts lists to tuples.
as_tuple
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/config.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/config.py
MIT
def common_logger_config(self, logger, config, incremental=False): """ Perform configuration which is common to root and non-root loggers. """ level = config.get('level', None) if level is not None: logger.setLevel(logging._checkLevel(level)) if not incrementa...
Perform configuration which is common to root and non-root loggers.
common_logger_config
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/config.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/config.py
MIT
def configure_logger(self, name, config, incremental=False): """Configure a non-root logger from a dictionary.""" logger = logging.getLogger(name) self.common_logger_config(logger, config, incremental) propagate = config.get('propagate', None) if propagate is not None: ...
Configure a non-root logger from a dictionary.
configure_logger
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/config.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/config.py
MIT
def listen(port=DEFAULT_LOGGING_CONFIG_PORT): """ Start up a socket server on the specified port, and listen for new configurations. These will be sent as a file suitable for processing by fileConfig(). Returns a Thread object on which you can call start() to start the server, and which you can...
Start up a socket server on the specified port, and listen for new configurations. These will be sent as a file suitable for processing by fileConfig(). Returns a Thread object on which you can call start() to start the server, and which you can join() when appropriate. To stop the server, call ...
listen
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/config.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/config.py
MIT
def handle(self): """ Handle a request. Each request is expected to be a 4-byte length, packed using struct.pack(">L", n), followed by the config file. Uses fileConfig() to do the grunt work. """ import tempfile try: ...
Handle a request. Each request is expected to be a 4-byte length, packed using struct.pack(">L", n), followed by the config file. Uses fileConfig() to do the grunt work.
handle
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/config.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/config.py
MIT
def stopListening(): """ Stop the listening server which was created with a call to listen(). """ global _listener logging._acquireLock() try: if _listener: _listener.abort = 1 _listener = None finally: logging._releaseLock()
Stop the listening server which was created with a call to listen().
stopListening
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/config.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/config.py
MIT
def __init__(self, filename, mode, encoding=None, delay=0): """ Use the specified filename for streamed logging """ if codecs is None: encoding = None logging.FileHandler.__init__(self, filename, mode, encoding, delay) self.mode = mode self.encoding = ...
Use the specified filename for streamed logging
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def __init__(self, filename, mode='a', maxBytes=0, backupCount=0, encoding=None, delay=0): """ Open the specified file and use it as the stream for logging. By default, the file grows indefinitely. You can specify particular values of maxBytes and backupCount to allow the file to rollov...
Open the specified file and use it as the stream for logging. By default, the file grows indefinitely. You can specify particular values of maxBytes and backupCount to allow the file to rollover at a predetermined size. Rollover occurs whenever the current log file is nearly m...
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def computeRollover(self, currentTime): """ Work out the rollover time based on the specified time. """ result = currentTime + self.interval # If we are rolling over at midnight or weekly, then the interval is already known. # What we need to figure out is WHEN the next i...
Work out the rollover time based on the specified time.
computeRollover
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def shouldRollover(self, record): """ Determine if rollover should occur. record is not used, as we are just comparing times, but it is needed so the method signatures are the same """ t = int(time.time()) if t >= self.rolloverAt: return 1 #pr...
Determine if rollover should occur. record is not used, as we are just comparing times, but it is needed so the method signatures are the same
shouldRollover
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def getFilesToDelete(self): """ Determine the files to delete when rolling over. More specific than the earlier method, which just used glob.glob(). """ dirName, baseName = os.path.split(self.baseFilename) fileNames = os.listdir(dirName) result = [] prefi...
Determine the files to delete when rolling over. More specific than the earlier method, which just used glob.glob().
getFilesToDelete
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def doRollover(self): """ do a rollover; in this case, a date/time stamp is appended to the filename when the rollover happens. However, you want the file to be named for the start of the interval, not the current time. If there is a backup count, then we have to get a list of ...
do a rollover; in this case, a date/time stamp is appended to the filename when the rollover happens. However, you want the file to be named for the start of the interval, not the current time. If there is a backup count, then we have to get a list of matching filenames, sort them and...
doRollover
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def __init__(self, host, port): """ Initializes the handler with a specific host address and port. The attribute 'closeOnError' is set to 1 - which means that if a socket error occurs, the socket is silently closed and then reopened on the next logging call. """ ...
Initializes the handler with a specific host address and port. The attribute 'closeOnError' is set to 1 - which means that if a socket error occurs, the socket is silently closed and then reopened on the next logging call.
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def makeSocket(self, timeout=1): """ A factory method which allows subclasses to define the precise type of socket they want. """ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) if hasattr(s, 'settimeout'): s.settimeout(timeout) s.connect((self.h...
A factory method which allows subclasses to define the precise type of socket they want.
makeSocket
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def createSocket(self): """ Try to create a socket, using an exponential backoff with a max retry time. Thanks to Robert Olson for the original patch (SF #815911) which has been slightly refactored. """ now = time.time() # Either retryTime is None, in which case t...
Try to create a socket, using an exponential backoff with a max retry time. Thanks to Robert Olson for the original patch (SF #815911) which has been slightly refactored.
createSocket
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def send(self, s): """ Send a pickled string to the socket. This function allows for partial sends which can happen when the network is busy. """ if self.sock is None: self.createSocket() #self.sock can be None either because we haven't reached the re...
Send a pickled string to the socket. This function allows for partial sends which can happen when the network is busy.
send
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def makePickle(self, record): """ Pickles the record in binary format with a length prefix, and returns it ready for transmission across the socket. """ ei = record.exc_info if ei: # just to get traceback text into record.exc_text ... dummy = self....
Pickles the record in binary format with a length prefix, and returns it ready for transmission across the socket.
makePickle
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def handleError(self, record): """ Handle an error during logging. An error has occurred during logging. Most likely cause - connection lost. Close the socket so that we can retry on the next event. """ if self.closeOnError and self.sock: self.sock.cl...
Handle an error during logging. An error has occurred during logging. Most likely cause - connection lost. Close the socket so that we can retry on the next event.
handleError
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def __init__(self, host, port): """ Initializes the handler with a specific host address and port. """ SocketHandler.__init__(self, host, port) self.closeOnError = 0
Initializes the handler with a specific host address and port.
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def send(self, s): """ Send a pickled string to a socket. This function no longer allows for partial sends which can happen when the network is busy - UDP does not guarantee delivery and can deliver packets out of sequence. """ if self.sock is None: s...
Send a pickled string to a socket. This function no longer allows for partial sends which can happen when the network is busy - UDP does not guarantee delivery and can deliver packets out of sequence.
send
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def __init__(self, address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER, socktype=None): """ Initialize a handler. If address is specified as a string, a UNIX socket is used. To log to a local syslogd, "SysLogHandler(address="/dev/log")" can be used. If fac...
Initialize a handler. If address is specified as a string, a UNIX socket is used. To log to a local syslogd, "SysLogHandler(address="/dev/log")" can be used. If facility is not specified, LOG_USER is used. If socktype is specified as socket.SOCK_DGRAM or socket.SOCK_STREAM, tha...
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def encodePriority(self, facility, priority): """ Encode the facility and priority. You can pass in strings or integers - if strings are passed, the facility_names and priority_names mapping dictionaries are used to convert them to integers. """ if isinstance(faci...
Encode the facility and priority. You can pass in strings or integers - if strings are passed, the facility_names and priority_names mapping dictionaries are used to convert them to integers.
encodePriority
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def __init__(self, mailhost, fromaddr, toaddrs, subject, credentials=None, secure=None): """ Initialize the handler. Initialize the instance with the from and to addresses and subject line of the email. To specify a non-standard SMTP port, use the (host, port) t...
Initialize the handler. Initialize the instance with the from and to addresses and subject line of the email. To specify a non-standard SMTP port, use the (host, port) tuple format for the mailhost argument. To specify authentication credentials, supply a (username, password) t...
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def __init__(self, host, url, method="GET"): """ Initialize the instance with the host, the request URL, and the method ("GET" or "POST") """ logging.Handler.__init__(self) method = method.upper() if method not in ["GET", "POST"]: raise ValueError("met...
Initialize the instance with the host, the request URL, and the method ("GET" or "POST")
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def __init__(self, capacity): """ Initialize the handler with the buffer size. """ logging.Handler.__init__(self) self.capacity = capacity self.buffer = []
Initialize the handler with the buffer size.
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def flush(self): """ Override to implement custom flushing behaviour. This version just zaps the buffer to empty. """ self.acquire() try: self.buffer = [] finally: self.release()
Override to implement custom flushing behaviour. This version just zaps the buffer to empty.
flush
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def close(self): """ Close the handler. This version just flushes and chains to the parent class' close(). """ try: self.flush() finally: logging.Handler.close(self)
Close the handler. This version just flushes and chains to the parent class' close().
close
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def __init__(self, capacity, flushLevel=logging.ERROR, target=None): """ Initialize the handler with the buffer size, the level at which flushing should occur and an optional target. Note that without a target being set either here or via setTarget(), a MemoryHandler is no use t...
Initialize the handler with the buffer size, the level at which flushing should occur and an optional target. Note that without a target being set either here or via setTarget(), a MemoryHandler is no use to anyone!
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def shouldFlush(self, record): """ Check for buffer full or a record at the flushLevel or higher. """ return (len(self.buffer) >= self.capacity) or \ (record.levelno >= self.flushLevel)
Check for buffer full or a record at the flushLevel or higher.
shouldFlush
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def flush(self): """ For a MemoryHandler, flushing means just sending the buffered records to the target, if there is one. Override if you want different behaviour. """ self.acquire() try: if self.target: for record in self.buffer: ...
For a MemoryHandler, flushing means just sending the buffered records to the target, if there is one. Override if you want different behaviour.
flush
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def close(self): """ Flush, set the target to None and lose the buffer. """ try: self.flush() finally: self.acquire() try: self.target = None BufferingHandler.close(self) finally: self...
Flush, set the target to None and lose the buffer.
close
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/handlers.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/handlers.py
MIT
def currentframe(): """Return the frame object for the caller's stack frame.""" try: raise Exception except: return sys.exc_info()[2].tb_frame.f_back
Return the frame object for the caller's stack frame.
currentframe
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/__init__.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/__init__.py
MIT
def addLevelName(level, levelName): """ Associate 'levelName' with 'level'. This is used when converting levels to text during message formatting. """ _acquireLock() try: #unlikely to cause an exception, but you never know... _levelNames[level] = levelName _levelNames[levelNa...
Associate 'levelName' with 'level'. This is used when converting levels to text during message formatting.
addLevelName
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/__init__.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/__init__.py
MIT
def __init__(self, name, level, pathname, lineno, msg, args, exc_info, func=None): """ Initialize a logging record with interesting information. """ ct = time.time() self.name = name self.msg = msg # # The following statement allows passin...
Initialize a logging record with interesting information.
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/__init__.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/__init__.py
MIT
def getMessage(self): """ Return the message for this LogRecord. Return the message for this LogRecord after merging any user-supplied arguments with the message. """ if not _unicode: #if no unicode support... msg = str(self.msg) else: msg...
Return the message for this LogRecord. Return the message for this LogRecord after merging any user-supplied arguments with the message.
getMessage
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/__init__.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/__init__.py
MIT
def makeLogRecord(dict): """ Make a LogRecord whose attributes are defined by the specified dictionary, This function is useful for converting a logging event received over a socket connection (which is sent as a dictionary) into a LogRecord instance. """ rv = LogRecord(None, None, "", 0, ""...
Make a LogRecord whose attributes are defined by the specified dictionary, This function is useful for converting a logging event received over a socket connection (which is sent as a dictionary) into a LogRecord instance.
makeLogRecord
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/__init__.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/__init__.py
MIT
def formatTime(self, record, datefmt=None): """ Return the creation time of the specified LogRecord as formatted text. This method should be called from format() by a formatter which wants to make use of a formatted time. This method can be overridden in formatters to provide fo...
Return the creation time of the specified LogRecord as formatted text. This method should be called from format() by a formatter which wants to make use of a formatted time. This method can be overridden in formatters to provide for any specific requirement, but the basic behav...
formatTime
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/__init__.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/__init__.py
MIT
def formatException(self, ei): """ Format and return the specified exception information as a string. This default implementation just uses traceback.print_exception() """ sio = cStringIO.StringIO() traceback.print_exception(ei[0], ei[1], ei[2], None, sio) ...
Format and return the specified exception information as a string. This default implementation just uses traceback.print_exception()
formatException
python
mchristopher/PokemonGo-DesktopMap
app/pywin/Lib/logging/__init__.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/logging/__init__.py
MIT