repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.merge_dupes
def merge_dupes(self): """Merge two entries that correspond to the same entry.""" for dupe in self.dupe_of: if dupe in self.catalog.entries: if self.catalog.entries[dupe]._stub: # merge = False to avoid infinite recursion self.catalog.l...
python
def merge_dupes(self): """Merge two entries that correspond to the same entry.""" for dupe in self.dupe_of: if dupe in self.catalog.entries: if self.catalog.entries[dupe]._stub: # merge = False to avoid infinite recursion self.catalog.l...
[ "def", "merge_dupes", "(", "self", ")", ":", "for", "dupe", "in", "self", ".", "dupe_of", ":", "if", "dupe", "in", "self", ".", "catalog", ".", "entries", ":", "if", "self", ".", "catalog", ".", "entries", "[", "dupe", "]", ".", "_stub", ":", "# me...
Merge two entries that correspond to the same entry.
[ "Merge", "two", "entries", "that", "correspond", "to", "the", "same", "entry", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L712-L723
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.add_quantity
def add_quantity(self, quantities, value, source, check_for_dupes=True, compare_to_existing=True, **kwargs): """Add an `Quantity` instance to this entry.""" success = True ...
python
def add_quantity(self, quantities, value, source, check_for_dupes=True, compare_to_existing=True, **kwargs): """Add an `Quantity` instance to this entry.""" success = True ...
[ "def", "add_quantity", "(", "self", ",", "quantities", ",", "value", ",", "source", ",", "check_for_dupes", "=", "True", ",", "compare_to_existing", "=", "True", ",", "*", "*", "kwargs", ")", ":", "success", "=", "True", "for", "quantity", "in", "listify",...
Add an `Quantity` instance to this entry.
[ "Add", "an", "Quantity", "instance", "to", "this", "entry", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L725-L746
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.add_self_source
def add_self_source(self): """Add a source that refers to the catalog itself. For now this points to the Open Supernova Catalog by default. """ return self.add_source( bibcode=self.catalog.OSC_BIBCODE, name=self.catalog.OSC_NAME, url=self.catalog.OSC_...
python
def add_self_source(self): """Add a source that refers to the catalog itself. For now this points to the Open Supernova Catalog by default. """ return self.add_source( bibcode=self.catalog.OSC_BIBCODE, name=self.catalog.OSC_NAME, url=self.catalog.OSC_...
[ "def", "add_self_source", "(", "self", ")", ":", "return", "self", ".", "add_source", "(", "bibcode", "=", "self", ".", "catalog", ".", "OSC_BIBCODE", ",", "name", "=", "self", ".", "catalog", ".", "OSC_NAME", ",", "url", "=", "self", ".", "catalog", "...
Add a source that refers to the catalog itself. For now this points to the Open Supernova Catalog by default.
[ "Add", "a", "source", "that", "refers", "to", "the", "catalog", "itself", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L748-L757
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.add_source
def add_source(self, allow_alias=False, **kwargs): """Add a `Source` instance to this entry.""" if not allow_alias and SOURCE.ALIAS in kwargs: err_str = "`{}` passed in kwargs, this shouldn't happen!".format( SOURCE.ALIAS) self._log.error(err_str) rais...
python
def add_source(self, allow_alias=False, **kwargs): """Add a `Source` instance to this entry.""" if not allow_alias and SOURCE.ALIAS in kwargs: err_str = "`{}` passed in kwargs, this shouldn't happen!".format( SOURCE.ALIAS) self._log.error(err_str) rais...
[ "def", "add_source", "(", "self", ",", "allow_alias", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "not", "allow_alias", "and", "SOURCE", ".", "ALIAS", "in", "kwargs", ":", "err_str", "=", "\"`{}` passed in kwargs, this shouldn't happen!\"", ".", "fo...
Add a `Source` instance to this entry.
[ "Add", "a", "Source", "instance", "to", "this", "entry", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L759-L779
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.add_model
def add_model(self, allow_alias=False, **kwargs): """Add a `Model` instance to this entry.""" if not allow_alias and MODEL.ALIAS in kwargs: err_str = "`{}` passed in kwargs, this shouldn't happen!".format( SOURCE.ALIAS) self._log.error(err_str) raise R...
python
def add_model(self, allow_alias=False, **kwargs): """Add a `Model` instance to this entry.""" if not allow_alias and MODEL.ALIAS in kwargs: err_str = "`{}` passed in kwargs, this shouldn't happen!".format( SOURCE.ALIAS) self._log.error(err_str) raise R...
[ "def", "add_model", "(", "self", ",", "allow_alias", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "not", "allow_alias", "and", "MODEL", ".", "ALIAS", "in", "kwargs", ":", "err_str", "=", "\"`{}` passed in kwargs, this shouldn't happen!\"", ".", "form...
Add a `Model` instance to this entry.
[ "Add", "a", "Model", "instance", "to", "this", "entry", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L781-L801
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.add_spectrum
def add_spectrum(self, compare_to_existing=True, **kwargs): """Add a `Spectrum` instance to this entry.""" spec_key = self._KEYS.SPECTRA # Make sure that a source is given, and is valid (nor erroneous) source = self._check_cat_dict_source(Spectrum, spec_key, **kwargs) if source i...
python
def add_spectrum(self, compare_to_existing=True, **kwargs): """Add a `Spectrum` instance to this entry.""" spec_key = self._KEYS.SPECTRA # Make sure that a source is given, and is valid (nor erroneous) source = self._check_cat_dict_source(Spectrum, spec_key, **kwargs) if source i...
[ "def", "add_spectrum", "(", "self", ",", "compare_to_existing", "=", "True", ",", "*", "*", "kwargs", ")", ":", "spec_key", "=", "self", ".", "_KEYS", ".", "SPECTRA", "# Make sure that a source is given, and is valid (nor erroneous)", "source", "=", "self", ".", "...
Add a `Spectrum` instance to this entry.
[ "Add", "a", "Spectrum", "instance", "to", "this", "entry", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L803-L831
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.check
def check(self): """Check that the entry has the required fields.""" # Make sure there is a schema key in dict if self._KEYS.SCHEMA not in self: self[self._KEYS.SCHEMA] = self.catalog.SCHEMA.URL # Make sure there is a name key in dict if (self._KEYS.NAME not in self o...
python
def check(self): """Check that the entry has the required fields.""" # Make sure there is a schema key in dict if self._KEYS.SCHEMA not in self: self[self._KEYS.SCHEMA] = self.catalog.SCHEMA.URL # Make sure there is a name key in dict if (self._KEYS.NAME not in self o...
[ "def", "check", "(", "self", ")", ":", "# Make sure there is a schema key in dict", "if", "self", ".", "_KEYS", ".", "SCHEMA", "not", "in", "self", ":", "self", "[", "self", ".", "_KEYS", ".", "SCHEMA", "]", "=", "self", ".", "catalog", ".", "SCHEMA", "....
Check that the entry has the required fields.
[ "Check", "that", "the", "entry", "has", "the", "required", "fields", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L833-L843
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.get_aliases
def get_aliases(self, includename=True): """Retrieve the aliases of this object as a list of strings. Arguments --------- includename : bool Include the 'name' parameter in the list of aliases. """ # empty list if doesnt exist alias_quanta = self.get(...
python
def get_aliases(self, includename=True): """Retrieve the aliases of this object as a list of strings. Arguments --------- includename : bool Include the 'name' parameter in the list of aliases. """ # empty list if doesnt exist alias_quanta = self.get(...
[ "def", "get_aliases", "(", "self", ",", "includename", "=", "True", ")", ":", "# empty list if doesnt exist", "alias_quanta", "=", "self", ".", "get", "(", "self", ".", "_KEYS", ".", "ALIAS", ",", "[", "]", ")", "aliases", "=", "[", "aq", "[", "QUANTITY"...
Retrieve the aliases of this object as a list of strings. Arguments --------- includename : bool Include the 'name' parameter in the list of aliases.
[ "Retrieve", "the", "aliases", "of", "this", "object", "as", "a", "list", "of", "strings", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L856-L869
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.get_entry_text
def get_entry_text(self, fname): """Retrieve the raw text from a file.""" if fname.split('.')[-1] == 'gz': with gz.open(fname, 'rt') as f: filetext = f.read() else: with codecs.open(fname, 'r') as f: filetext = f.read() return filet...
python
def get_entry_text(self, fname): """Retrieve the raw text from a file.""" if fname.split('.')[-1] == 'gz': with gz.open(fname, 'rt') as f: filetext = f.read() else: with codecs.open(fname, 'r') as f: filetext = f.read() return filet...
[ "def", "get_entry_text", "(", "self", ",", "fname", ")", ":", "if", "fname", ".", "split", "(", "'.'", ")", "[", "-", "1", "]", "==", "'gz'", ":", "with", "gz", ".", "open", "(", "fname", ",", "'rt'", ")", "as", "f", ":", "filetext", "=", "f", ...
Retrieve the raw text from a file.
[ "Retrieve", "the", "raw", "text", "from", "a", "file", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L871-L879
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.get_source_by_alias
def get_source_by_alias(self, alias): """Given an alias, find the corresponding source in this entry. If the given alias doesn't exist (e.g. there are no sources), then a `ValueError` is raised. Arguments --------- alias : str The str-integer (e.g. '8') of t...
python
def get_source_by_alias(self, alias): """Given an alias, find the corresponding source in this entry. If the given alias doesn't exist (e.g. there are no sources), then a `ValueError` is raised. Arguments --------- alias : str The str-integer (e.g. '8') of t...
[ "def", "get_source_by_alias", "(", "self", ",", "alias", ")", ":", "for", "source", "in", "self", ".", "get", "(", "self", ".", "_KEYS", ".", "SOURCES", ",", "[", "]", ")", ":", "if", "source", "[", "self", ".", "_KEYS", ".", "ALIAS", "]", "==", ...
Given an alias, find the corresponding source in this entry. If the given alias doesn't exist (e.g. there are no sources), then a `ValueError` is raised. Arguments --------- alias : str The str-integer (e.g. '8') of the target source. Returns ------...
[ "Given", "an", "alias", "find", "the", "corresponding", "source", "in", "this", "entry", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L881-L902
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.get_stub
def get_stub(self): """Get a new `Entry` which contains the 'stub' of this one. The 'stub' is only the name and aliases. Usage: ----- To convert a normal entry into a stub (for example), overwrite the entry in place, i.e. >>> entries[name] = entries[name].get_st...
python
def get_stub(self): """Get a new `Entry` which contains the 'stub' of this one. The 'stub' is only the name and aliases. Usage: ----- To convert a normal entry into a stub (for example), overwrite the entry in place, i.e. >>> entries[name] = entries[name].get_st...
[ "def", "get_stub", "(", "self", ")", ":", "stub", "=", "type", "(", "self", ")", "(", "self", ".", "catalog", ",", "self", "[", "self", ".", "_KEYS", ".", "NAME", "]", ",", "stub", "=", "True", ")", "if", "self", ".", "_KEYS", ".", "ALIAS", "in...
Get a new `Entry` which contains the 'stub' of this one. The 'stub' is only the name and aliases. Usage: ----- To convert a normal entry into a stub (for example), overwrite the entry in place, i.e. >>> entries[name] = entries[name].get_stub() Returns -...
[ "Get", "a", "new", "Entry", "which", "contains", "the", "stub", "of", "this", "one", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L904-L934
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.is_erroneous
def is_erroneous(self, field, sources): """Check if attribute has been marked as being erroneous.""" if self._KEYS.ERRORS in self: my_errors = self[self._KEYS.ERRORS] for alias in sources.split(','): source = self.get_source_by_alias(alias) bib_err...
python
def is_erroneous(self, field, sources): """Check if attribute has been marked as being erroneous.""" if self._KEYS.ERRORS in self: my_errors = self[self._KEYS.ERRORS] for alias in sources.split(','): source = self.get_source_by_alias(alias) bib_err...
[ "def", "is_erroneous", "(", "self", ",", "field", ",", "sources", ")", ":", "if", "self", ".", "_KEYS", ".", "ERRORS", "in", "self", ":", "my_errors", "=", "self", "[", "self", ".", "_KEYS", ".", "ERRORS", "]", "for", "alias", "in", "sources", ".", ...
Check if attribute has been marked as being erroneous.
[ "Check", "if", "attribute", "has", "been", "marked", "as", "being", "erroneous", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L936-L960
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.is_private
def is_private(self, key, sources): """Check if attribute is private.""" # aliases are always public. if key == ENTRY.ALIAS: return False return all([ SOURCE.PRIVATE in self.get_source_by_alias(x) for x in sources.split(',') ])
python
def is_private(self, key, sources): """Check if attribute is private.""" # aliases are always public. if key == ENTRY.ALIAS: return False return all([ SOURCE.PRIVATE in self.get_source_by_alias(x) for x in sources.split(',') ])
[ "def", "is_private", "(", "self", ",", "key", ",", "sources", ")", ":", "# aliases are always public.", "if", "key", "==", "ENTRY", ".", "ALIAS", ":", "return", "False", "return", "all", "(", "[", "SOURCE", ".", "PRIVATE", "in", "self", ".", "get_source_by...
Check if attribute is private.
[ "Check", "if", "attribute", "is", "private", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L962-L970
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.sanitize
def sanitize(self): """Sanitize the data (sort it, etc.) before writing it to disk. Template method that can be overridden in each catalog's subclassed `Entry` object. """ name = self[self._KEYS.NAME] aliases = self.get_aliases(includename=False) if name not in ...
python
def sanitize(self): """Sanitize the data (sort it, etc.) before writing it to disk. Template method that can be overridden in each catalog's subclassed `Entry` object. """ name = self[self._KEYS.NAME] aliases = self.get_aliases(includename=False) if name not in ...
[ "def", "sanitize", "(", "self", ")", ":", "name", "=", "self", "[", "self", ".", "_KEYS", ".", "NAME", "]", "aliases", "=", "self", ".", "get_aliases", "(", "includename", "=", "False", ")", "if", "name", "not", "in", "aliases", ":", "# Assign the firs...
Sanitize the data (sort it, etc.) before writing it to disk. Template method that can be overridden in each catalog's subclassed `Entry` object.
[ "Sanitize", "the", "data", "(", "sort", "it", "etc", ".", ")", "before", "writing", "it", "to", "disk", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L1003-L1086
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.save
def save(self, bury=False, final=False): """Write entry to JSON file in the proper location. Arguments --------- bury : bool final : bool If this is the 'final' save, perform additional sanitization and cleaning operations. """ outdir, f...
python
def save(self, bury=False, final=False): """Write entry to JSON file in the proper location. Arguments --------- bury : bool final : bool If this is the 'final' save, perform additional sanitization and cleaning operations. """ outdir, f...
[ "def", "save", "(", "self", ",", "bury", "=", "False", ",", "final", "=", "False", ")", ":", "outdir", ",", "filename", "=", "self", ".", "_get_save_path", "(", "bury", "=", "bury", ")", "if", "final", ":", "self", ".", "sanitize", "(", ")", "# FIX...
Write entry to JSON file in the proper location. Arguments --------- bury : bool final : bool If this is the 'final' save, perform additional sanitization and cleaning operations.
[ "Write", "entry", "to", "JSON", "file", "in", "the", "proper", "location", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L1088-L1124
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.sort_func
def sort_func(self, key): """Used to sort keys when writing Entry to JSON format. Should be supplemented/overridden by inheriting classes. """ if key == self._KEYS.SCHEMA: return 'aaa' if key == self._KEYS.NAME: return 'aab' if key == self._KEYS.S...
python
def sort_func(self, key): """Used to sort keys when writing Entry to JSON format. Should be supplemented/overridden by inheriting classes. """ if key == self._KEYS.SCHEMA: return 'aaa' if key == self._KEYS.NAME: return 'aab' if key == self._KEYS.S...
[ "def", "sort_func", "(", "self", ",", "key", ")", ":", "if", "key", "==", "self", ".", "_KEYS", ".", "SCHEMA", ":", "return", "'aaa'", "if", "key", "==", "self", ".", "_KEYS", ".", "NAME", ":", "return", "'aab'", "if", "key", "==", "self", ".", "...
Used to sort keys when writing Entry to JSON format. Should be supplemented/overridden by inheriting classes.
[ "Used", "to", "sort", "keys", "when", "writing", "Entry", "to", "JSON", "format", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L1130-L1149
train
astrocatalogs/astrocats
astrocats/catalog/photometry.py
set_pd_mag_from_counts
def set_pd_mag_from_counts(photodict, c='', ec='', lec='', uec='', zp=DEFAULT_ZP, sig=DEFAULT_UL_SIGMA): """Set photometry dictionary from a counts measur...
python
def set_pd_mag_from_counts(photodict, c='', ec='', lec='', uec='', zp=DEFAULT_ZP, sig=DEFAULT_UL_SIGMA): """Set photometry dictionary from a counts measur...
[ "def", "set_pd_mag_from_counts", "(", "photodict", ",", "c", "=", "''", ",", "ec", "=", "''", ",", "lec", "=", "''", ",", "uec", "=", "''", ",", "zp", "=", "DEFAULT_ZP", ",", "sig", "=", "DEFAULT_UL_SIGMA", ")", ":", "with", "localcontext", "(", ")",...
Set photometry dictionary from a counts measurement.
[ "Set", "photometry", "dictionary", "from", "a", "counts", "measurement", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/photometry.py#L421-L459
train
astrocatalogs/astrocats
astrocats/catalog/photometry.py
set_pd_mag_from_flux_density
def set_pd_mag_from_flux_density(photodict, fd='', efd='', lefd='', uefd='', sig=DEFAULT_UL_SIGMA): """Set photometry dictionary from a flux density me...
python
def set_pd_mag_from_flux_density(photodict, fd='', efd='', lefd='', uefd='', sig=DEFAULT_UL_SIGMA): """Set photometry dictionary from a flux density me...
[ "def", "set_pd_mag_from_flux_density", "(", "photodict", ",", "fd", "=", "''", ",", "efd", "=", "''", ",", "lefd", "=", "''", ",", "uefd", "=", "''", ",", "sig", "=", "DEFAULT_UL_SIGMA", ")", ":", "with", "localcontext", "(", ")", "as", "ctx", ":", "...
Set photometry dictionary from a flux density measurement. `fd` is assumed to be in microjanskys.
[ "Set", "photometry", "dictionary", "from", "a", "flux", "density", "measurement", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/photometry.py#L462-L500
train
astrocatalogs/astrocats
astrocats/catalog/photometry.py
Photometry._check
def _check(self): """Check that entry attributes are legal.""" # Run the super method super(Photometry, self)._check() err_str = None has_flux = self._KEYS.FLUX in self has_flux_dens = self._KEYS.FLUX_DENSITY in self has_u_flux = self._KEYS.U_FLUX in self ...
python
def _check(self): """Check that entry attributes are legal.""" # Run the super method super(Photometry, self)._check() err_str = None has_flux = self._KEYS.FLUX in self has_flux_dens = self._KEYS.FLUX_DENSITY in self has_u_flux = self._KEYS.U_FLUX in self ...
[ "def", "_check", "(", "self", ")", ":", "# Run the super method", "super", "(", "Photometry", ",", "self", ")", ".", "_check", "(", ")", "err_str", "=", "None", "has_flux", "=", "self", ".", "_KEYS", ".", "FLUX", "in", "self", "has_flux_dens", "=", "self...
Check that entry attributes are legal.
[ "Check", "that", "entry", "attributes", "are", "legal", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/photometry.py#L168-L208
train
astrocatalogs/astrocats
astrocats/catalog/photometry.py
Photometry.sort_func
def sort_func(self, key): """Specify order for attributes.""" if key == self._KEYS.TIME: return 'aaa' if key == self._KEYS.MODEL: return 'zzy' if key == self._KEYS.SOURCE: return 'zzz' return key
python
def sort_func(self, key): """Specify order for attributes.""" if key == self._KEYS.TIME: return 'aaa' if key == self._KEYS.MODEL: return 'zzy' if key == self._KEYS.SOURCE: return 'zzz' return key
[ "def", "sort_func", "(", "self", ",", "key", ")", ":", "if", "key", "==", "self", ".", "_KEYS", ".", "TIME", ":", "return", "'aaa'", "if", "key", "==", "self", ".", "_KEYS", ".", "MODEL", ":", "return", "'zzy'", "if", "key", "==", "self", ".", "_...
Specify order for attributes.
[ "Specify", "order", "for", "attributes", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/photometry.py#L221-L229
train
ergo/ziggurat_foundations
ziggurat_foundations/migrations/env.py
run_migrations_offline
def run_migrations_offline(): """Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the g...
python
def run_migrations_offline(): """Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the g...
[ "def", "run_migrations_offline", "(", ")", ":", "url", "=", "get_url", "(", ")", "context", ".", "configure", "(", "url", "=", "url", ",", "version_table", "=", "\"alembic_ziggurat_foundations_version\"", ",", "transaction_per_migration", "=", "True", ",", ")", ...
Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the given string to the script output.
[ "Run", "migrations", "in", "offline", "mode", "." ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/migrations/env.py#L51-L71
train
ergo/ziggurat_foundations
ziggurat_foundations/migrations/env.py
run_migrations_online
def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ engine = create_engine(get_url()) connection = engine.connect() context.configure( connection=connection, target_m...
python
def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ engine = create_engine(get_url()) connection = engine.connect() context.configure( connection=connection, target_m...
[ "def", "run_migrations_online", "(", ")", ":", "engine", "=", "create_engine", "(", "get_url", "(", ")", ")", "connection", "=", "engine", ".", "connect", "(", ")", "context", ".", "configure", "(", "connection", "=", "connection", ",", "target_metadata", "=...
Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context.
[ "Run", "migrations", "in", "online", "mode", "." ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/migrations/env.py#L74-L95
train
ergo/ziggurat_foundations
ziggurat_foundations/models/services/user_resource_permission.py
UserResourcePermissionService.by_resource_user_and_perm
def by_resource_user_and_perm( cls, user_id, perm_name, resource_id, db_session=None ): """ return all instances by user name, perm name and resource id :param user_id: :param perm_name: :param resource_id: :param db_session: :return: """ ...
python
def by_resource_user_and_perm( cls, user_id, perm_name, resource_id, db_session=None ): """ return all instances by user name, perm name and resource id :param user_id: :param perm_name: :param resource_id: :param db_session: :return: """ ...
[ "def", "by_resource_user_and_perm", "(", "cls", ",", "user_id", ",", "perm_name", ",", "resource_id", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls", ...
return all instances by user name, perm name and resource id :param user_id: :param perm_name: :param resource_id: :param db_session: :return:
[ "return", "all", "instances", "by", "user", "name", "perm", "name", "and", "resource", "id" ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user_resource_permission.py#L27-L44
train
erijo/tellcore-py
tellcore/library.py
Library.tdSensor
def tdSensor(self): """Get the next sensor while iterating. :return: a dict with the keys: protocol, model, id, datatypes. """ protocol = create_string_buffer(20) model = create_string_buffer(20) sid = c_int() datatypes = c_int() self._lib.tdSensor(proto...
python
def tdSensor(self): """Get the next sensor while iterating. :return: a dict with the keys: protocol, model, id, datatypes. """ protocol = create_string_buffer(20) model = create_string_buffer(20) sid = c_int() datatypes = c_int() self._lib.tdSensor(proto...
[ "def", "tdSensor", "(", "self", ")", ":", "protocol", "=", "create_string_buffer", "(", "20", ")", "model", "=", "create_string_buffer", "(", "20", ")", "sid", "=", "c_int", "(", ")", "datatypes", "=", "c_int", "(", ")", "self", ".", "_lib", ".", "tdSe...
Get the next sensor while iterating. :return: a dict with the keys: protocol, model, id, datatypes.
[ "Get", "the", "next", "sensor", "while", "iterating", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/library.py#L409-L423
train
erijo/tellcore-py
tellcore/library.py
Library.tdSensorValue
def tdSensorValue(self, protocol, model, sid, datatype): """Get the sensor value for a given sensor. :return: a dict with the keys: value, timestamp. """ value = create_string_buffer(20) timestamp = c_int() self._lib.tdSensorValue(protocol, model, sid, datatype, ...
python
def tdSensorValue(self, protocol, model, sid, datatype): """Get the sensor value for a given sensor. :return: a dict with the keys: value, timestamp. """ value = create_string_buffer(20) timestamp = c_int() self._lib.tdSensorValue(protocol, model, sid, datatype, ...
[ "def", "tdSensorValue", "(", "self", ",", "protocol", ",", "model", ",", "sid", ",", "datatype", ")", ":", "value", "=", "create_string_buffer", "(", "20", ")", "timestamp", "=", "c_int", "(", ")", "self", ".", "_lib", ".", "tdSensorValue", "(", "protoco...
Get the sensor value for a given sensor. :return: a dict with the keys: value, timestamp.
[ "Get", "the", "sensor", "value", "for", "a", "given", "sensor", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/library.py#L425-L435
train
erijo/tellcore-py
tellcore/library.py
Library.tdController
def tdController(self): """Get the next controller while iterating. :return: a dict with the keys: id, type, name, available. """ cid = c_int() ctype = c_int() name = create_string_buffer(255) available = c_int() self._lib.tdController(byref(cid), byref(...
python
def tdController(self): """Get the next controller while iterating. :return: a dict with the keys: id, type, name, available. """ cid = c_int() ctype = c_int() name = create_string_buffer(255) available = c_int() self._lib.tdController(byref(cid), byref(...
[ "def", "tdController", "(", "self", ")", ":", "cid", "=", "c_int", "(", ")", "ctype", "=", "c_int", "(", ")", "name", "=", "create_string_buffer", "(", "255", ")", "available", "=", "c_int", "(", ")", "self", ".", "_lib", ".", "tdController", "(", "b...
Get the next controller while iterating. :return: a dict with the keys: id, type, name, available.
[ "Get", "the", "next", "controller", "while", "iterating", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/library.py#L437-L450
train
ergo/ziggurat_foundations
ziggurat_foundations/__init__.py
make_passwordmanager
def make_passwordmanager(schemes=None): """ schemes contains a list of replace this list with the hash(es) you wish to support. this example sets pbkdf2_sha256 as the default, with support for legacy bcrypt hashes. :param schemes: :return: CryptContext() """ from passlib.context imp...
python
def make_passwordmanager(schemes=None): """ schemes contains a list of replace this list with the hash(es) you wish to support. this example sets pbkdf2_sha256 as the default, with support for legacy bcrypt hashes. :param schemes: :return: CryptContext() """ from passlib.context imp...
[ "def", "make_passwordmanager", "(", "schemes", "=", "None", ")", ":", "from", "passlib", ".", "context", "import", "CryptContext", "if", "not", "schemes", ":", "schemes", "=", "[", "\"pbkdf2_sha256\"", ",", "\"bcrypt\"", "]", "pwd_context", "=", "CryptContext", ...
schemes contains a list of replace this list with the hash(es) you wish to support. this example sets pbkdf2_sha256 as the default, with support for legacy bcrypt hashes. :param schemes: :return: CryptContext()
[ "schemes", "contains", "a", "list", "of", "replace", "this", "list", "with", "the", "hash", "(", "es", ")", "you", "wish", "to", "support", ".", "this", "example", "sets", "pbkdf2_sha256", "as", "the", "default", "with", "support", "for", "legacy", "bcrypt...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/__init__.py#L43-L58
train
ergo/ziggurat_foundations
ziggurat_foundations/__init__.py
ziggurat_model_init
def ziggurat_model_init( user=None, group=None, user_group=None, group_permission=None, user_permission=None, user_resource_permission=None, group_resource_permission=None, resource=None, external_identity=None, *args, **kwargs ): """ This function handles attaching m...
python
def ziggurat_model_init( user=None, group=None, user_group=None, group_permission=None, user_permission=None, user_resource_permission=None, group_resource_permission=None, resource=None, external_identity=None, *args, **kwargs ): """ This function handles attaching m...
[ "def", "ziggurat_model_init", "(", "user", "=", "None", ",", "group", "=", "None", ",", "user_group", "=", "None", ",", "group_permission", "=", "None", ",", "user_permission", "=", "None", ",", "user_resource_permission", "=", "None", ",", "group_resource_permi...
This function handles attaching model to service if model has one specified as `_ziggurat_service`, Also attached a proxy object holding all model definitions that services might use :param args: :param kwargs: :param passwordmanager, the password manager to override default one :param password...
[ "This", "function", "handles", "attaching", "model", "to", "service", "if", "model", "has", "one", "specified", "as", "_ziggurat_service", "Also", "attached", "a", "proxy", "object", "holding", "all", "model", "definitions", "that", "services", "might", "use" ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/__init__.py#L61-L111
train
stephenmcd/gnotty
gnotty/views.py
messages
def messages(request, year=None, month=None, day=None, template="gnotty/messages.html"): """ Show messages for the given query or day. """ query = request.REQUEST.get("q") prev_url, next_url = None, None messages = IRCMessage.objects.all() if hide_joins_and_leaves(request): ...
python
def messages(request, year=None, month=None, day=None, template="gnotty/messages.html"): """ Show messages for the given query or day. """ query = request.REQUEST.get("q") prev_url, next_url = None, None messages = IRCMessage.objects.all() if hide_joins_and_leaves(request): ...
[ "def", "messages", "(", "request", ",", "year", "=", "None", ",", "month", "=", "None", ",", "day", "=", "None", ",", "template", "=", "\"gnotty/messages.html\"", ")", ":", "query", "=", "request", ".", "REQUEST", ".", "get", "(", "\"q\"", ")", "prev_u...
Show messages for the given query or day.
[ "Show", "messages", "for", "the", "given", "query", "or", "day", "." ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/views.py#L25-L56
train
stephenmcd/gnotty
gnotty/views.py
calendar
def calendar(request, year=None, month=None, template="gnotty/calendar.html"): """ Show calendar months for the given year/month. """ try: year = int(year) except TypeError: year = datetime.now().year lookup = {"message_time__year": year} if month: lookup["message_ti...
python
def calendar(request, year=None, month=None, template="gnotty/calendar.html"): """ Show calendar months for the given year/month. """ try: year = int(year) except TypeError: year = datetime.now().year lookup = {"message_time__year": year} if month: lookup["message_ti...
[ "def", "calendar", "(", "request", ",", "year", "=", "None", ",", "month", "=", "None", ",", "template", "=", "\"gnotty/calendar.html\"", ")", ":", "try", ":", "year", "=", "int", "(", "year", ")", "except", "TypeError", ":", "year", "=", "datetime", "...
Show calendar months for the given year/month.
[ "Show", "calendar", "months", "for", "the", "given", "year", "/", "month", "." ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/views.py#L59-L102
train
Yelp/swagger_zipkin
swagger_zipkin/decorate_client.py
decorate_client
def decorate_client(api_client, func, name): """A helper for decorating :class:`bravado.client.SwaggerClient`. :class:`bravado.client.SwaggerClient` can be extended by creating a class which wraps all calls to it. This helper is used in a :func:`__getattr__` to check if the attr exists on the api_client...
python
def decorate_client(api_client, func, name): """A helper for decorating :class:`bravado.client.SwaggerClient`. :class:`bravado.client.SwaggerClient` can be extended by creating a class which wraps all calls to it. This helper is used in a :func:`__getattr__` to check if the attr exists on the api_client...
[ "def", "decorate_client", "(", "api_client", ",", "func", ",", "name", ")", ":", "client_attr", "=", "getattr", "(", "api_client", ",", "name", ")", "if", "not", "callable", "(", "client_attr", ")", ":", "return", "client_attr", "return", "OperationDecorator",...
A helper for decorating :class:`bravado.client.SwaggerClient`. :class:`bravado.client.SwaggerClient` can be extended by creating a class which wraps all calls to it. This helper is used in a :func:`__getattr__` to check if the attr exists on the api_client. If the attr does not exist raise :class:`Attri...
[ "A", "helper", "for", "decorating", ":", "class", ":", "bravado", ".", "client", ".", "SwaggerClient", ".", ":", "class", ":", "bravado", ".", "client", ".", "SwaggerClient", "can", "be", "extended", "by", "creating", "a", "class", "which", "wraps", "all",...
8159b5d04f2c1089ae0a60851a5f097d7e09a40e
https://github.com/Yelp/swagger_zipkin/blob/8159b5d04f2c1089ae0a60851a5f097d7e09a40e/swagger_zipkin/decorate_client.py#L33-L71
train
ambitioninc/django-db-mutex
db_mutex/db_mutex.py
db_mutex.delete_expired_locks
def delete_expired_locks(self): """ Deletes all expired mutex locks if a ttl is provided. """ ttl_seconds = self.get_mutex_ttl_seconds() if ttl_seconds is not None: DBMutex.objects.filter(creation_time__lte=timezone.now() - timedelta(seconds=ttl_seconds)).delete()
python
def delete_expired_locks(self): """ Deletes all expired mutex locks if a ttl is provided. """ ttl_seconds = self.get_mutex_ttl_seconds() if ttl_seconds is not None: DBMutex.objects.filter(creation_time__lte=timezone.now() - timedelta(seconds=ttl_seconds)).delete()
[ "def", "delete_expired_locks", "(", "self", ")", ":", "ttl_seconds", "=", "self", ".", "get_mutex_ttl_seconds", "(", ")", "if", "ttl_seconds", "is", "not", "None", ":", "DBMutex", ".", "objects", ".", "filter", "(", "creation_time__lte", "=", "timezone", ".", ...
Deletes all expired mutex locks if a ttl is provided.
[ "Deletes", "all", "expired", "mutex", "locks", "if", "a", "ttl", "is", "provided", "." ]
7112ed202fa3135afbb280273c1bdc8dee4e8426
https://github.com/ambitioninc/django-db-mutex/blob/7112ed202fa3135afbb280273c1bdc8dee4e8426/db_mutex/db_mutex.py#L81-L87
train
ambitioninc/django-db-mutex
db_mutex/db_mutex.py
db_mutex.start
def start(self): """ Acquires the db mutex lock. Takes the necessary steps to delete any stale locks. Throws a DBMutexError if it can't acquire the lock. """ # Delete any expired locks first self.delete_expired_locks() try: with transaction.atomic(): ...
python
def start(self): """ Acquires the db mutex lock. Takes the necessary steps to delete any stale locks. Throws a DBMutexError if it can't acquire the lock. """ # Delete any expired locks first self.delete_expired_locks() try: with transaction.atomic(): ...
[ "def", "start", "(", "self", ")", ":", "# Delete any expired locks first", "self", ".", "delete_expired_locks", "(", ")", "try", ":", "with", "transaction", ".", "atomic", "(", ")", ":", "self", ".", "lock", "=", "DBMutex", ".", "objects", ".", "create", "...
Acquires the db mutex lock. Takes the necessary steps to delete any stale locks. Throws a DBMutexError if it can't acquire the lock.
[ "Acquires", "the", "db", "mutex", "lock", ".", "Takes", "the", "necessary", "steps", "to", "delete", "any", "stale", "locks", ".", "Throws", "a", "DBMutexError", "if", "it", "can", "t", "acquire", "the", "lock", "." ]
7112ed202fa3135afbb280273c1bdc8dee4e8426
https://github.com/ambitioninc/django-db-mutex/blob/7112ed202fa3135afbb280273c1bdc8dee4e8426/db_mutex/db_mutex.py#L98-L109
train
ambitioninc/django-db-mutex
db_mutex/db_mutex.py
db_mutex.stop
def stop(self): """ Releases the db mutex lock. Throws an error if the lock was released before the function finished. """ if not DBMutex.objects.filter(id=self.lock.id).exists(): raise DBMutexTimeoutError('Lock {0} expired before function completed'.format(self.lock_id)) ...
python
def stop(self): """ Releases the db mutex lock. Throws an error if the lock was released before the function finished. """ if not DBMutex.objects.filter(id=self.lock.id).exists(): raise DBMutexTimeoutError('Lock {0} expired before function completed'.format(self.lock_id)) ...
[ "def", "stop", "(", "self", ")", ":", "if", "not", "DBMutex", ".", "objects", ".", "filter", "(", "id", "=", "self", ".", "lock", ".", "id", ")", ".", "exists", "(", ")", ":", "raise", "DBMutexTimeoutError", "(", "'Lock {0} expired before function complete...
Releases the db mutex lock. Throws an error if the lock was released before the function finished.
[ "Releases", "the", "db", "mutex", "lock", ".", "Throws", "an", "error", "if", "the", "lock", "was", "released", "before", "the", "function", "finished", "." ]
7112ed202fa3135afbb280273c1bdc8dee4e8426
https://github.com/ambitioninc/django-db-mutex/blob/7112ed202fa3135afbb280273c1bdc8dee4e8426/db_mutex/db_mutex.py#L111-L118
train
ambitioninc/django-db-mutex
db_mutex/db_mutex.py
db_mutex.decorate_callable
def decorate_callable(self, func): """ Decorates a function with the db_mutex decorator by using this class as a context manager around it. """ def wrapper(*args, **kwargs): try: with self: result = func(*args, **kwargs) ...
python
def decorate_callable(self, func): """ Decorates a function with the db_mutex decorator by using this class as a context manager around it. """ def wrapper(*args, **kwargs): try: with self: result = func(*args, **kwargs) ...
[ "def", "decorate_callable", "(", "self", ",", "func", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "with", "self", ":", "result", "=", "func", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return...
Decorates a function with the db_mutex decorator by using this class as a context manager around it.
[ "Decorates", "a", "function", "with", "the", "db_mutex", "decorator", "by", "using", "this", "class", "as", "a", "context", "manager", "around", "it", "." ]
7112ed202fa3135afbb280273c1bdc8dee4e8426
https://github.com/ambitioninc/django-db-mutex/blob/7112ed202fa3135afbb280273c1bdc8dee4e8426/db_mutex/db_mutex.py#L120-L136
train
ergo/ziggurat_foundations
ziggurat_foundations/models/__init__.py
groupfinder
def groupfinder(userid, request): """ Default groupfinder implementaion for pyramid applications :param userid: :param request: :return: """ if userid and hasattr(request, "user") and request.user: groups = ["group:%s" % g.id for g in request.user.groups] return groups r...
python
def groupfinder(userid, request): """ Default groupfinder implementaion for pyramid applications :param userid: :param request: :return: """ if userid and hasattr(request, "user") and request.user: groups = ["group:%s" % g.id for g in request.user.groups] return groups r...
[ "def", "groupfinder", "(", "userid", ",", "request", ")", ":", "if", "userid", "and", "hasattr", "(", "request", ",", "\"user\"", ")", "and", "request", ".", "user", ":", "groups", "=", "[", "\"group:%s\"", "%", "g", ".", "id", "for", "g", "in", "req...
Default groupfinder implementaion for pyramid applications :param userid: :param request: :return:
[ "Default", "groupfinder", "implementaion", "for", "pyramid", "applications" ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/__init__.py#L7-L18
train
bosiakov/fa2l
fa2l/fa2l.py
force_atlas2_layout
def force_atlas2_layout(graph, pos_list=None, node_masses=None, iterations=100, outbound_attraction_distribution=False, lin_log_mode=False, prevent_overlapping=False, ...
python
def force_atlas2_layout(graph, pos_list=None, node_masses=None, iterations=100, outbound_attraction_distribution=False, lin_log_mode=False, prevent_overlapping=False, ...
[ "def", "force_atlas2_layout", "(", "graph", ",", "pos_list", "=", "None", ",", "node_masses", "=", "None", ",", "iterations", "=", "100", ",", "outbound_attraction_distribution", "=", "False", ",", "lin_log_mode", "=", "False", ",", "prevent_overlapping", "=", "...
Position nodes using ForceAtlas2 force-directed algorithm Parameters ---------- graph: NetworkX graph A position will be assigned to every node in G. pos_list : dict or None optional (default=None) Initial positions for nodes as a dictionary with node as keys and values as a c...
[ "Position", "nodes", "using", "ForceAtlas2", "force", "-", "directed", "algorithm" ]
46b8494c2ad4429bbe1042b6e87b139dd7422c31
https://github.com/bosiakov/fa2l/blob/46b8494c2ad4429bbe1042b6e87b139dd7422c31/fa2l/fa2l.py#L10-L243
train
bosiakov/fa2l
fa2l/force.py
apply_repulsion
def apply_repulsion(repulsion, nodes, barnes_hut_optimize=False, region=None, barnes_hut_theta=1.2): """ Iterate through the nodes or edges and apply the forces directly to the node objects. """ if not barnes_hut_optimize: for i in range(0, len(nodes)): for j in range(0, i): ...
python
def apply_repulsion(repulsion, nodes, barnes_hut_optimize=False, region=None, barnes_hut_theta=1.2): """ Iterate through the nodes or edges and apply the forces directly to the node objects. """ if not barnes_hut_optimize: for i in range(0, len(nodes)): for j in range(0, i): ...
[ "def", "apply_repulsion", "(", "repulsion", ",", "nodes", ",", "barnes_hut_optimize", "=", "False", ",", "region", "=", "None", ",", "barnes_hut_theta", "=", "1.2", ")", ":", "if", "not", "barnes_hut_optimize", ":", "for", "i", "in", "range", "(", "0", ","...
Iterate through the nodes or edges and apply the forces directly to the node objects.
[ "Iterate", "through", "the", "nodes", "or", "edges", "and", "apply", "the", "forces", "directly", "to", "the", "node", "objects", "." ]
46b8494c2ad4429bbe1042b6e87b139dd7422c31
https://github.com/bosiakov/fa2l/blob/46b8494c2ad4429bbe1042b6e87b139dd7422c31/fa2l/force.py#L4-L14
train
bosiakov/fa2l
fa2l/force.py
apply_gravity
def apply_gravity(repulsion, nodes, gravity, scaling_ratio): """ Iterate through the nodes or edges and apply the gravity directly to the node objects. """ for i in range(0, len(nodes)): repulsion.apply_gravitation(nodes[i], gravity / scaling_ratio)
python
def apply_gravity(repulsion, nodes, gravity, scaling_ratio): """ Iterate through the nodes or edges and apply the gravity directly to the node objects. """ for i in range(0, len(nodes)): repulsion.apply_gravitation(nodes[i], gravity / scaling_ratio)
[ "def", "apply_gravity", "(", "repulsion", ",", "nodes", ",", "gravity", ",", "scaling_ratio", ")", ":", "for", "i", "in", "range", "(", "0", ",", "len", "(", "nodes", ")", ")", ":", "repulsion", ".", "apply_gravitation", "(", "nodes", "[", "i", "]", ...
Iterate through the nodes or edges and apply the gravity directly to the node objects.
[ "Iterate", "through", "the", "nodes", "or", "edges", "and", "apply", "the", "gravity", "directly", "to", "the", "node", "objects", "." ]
46b8494c2ad4429bbe1042b6e87b139dd7422c31
https://github.com/bosiakov/fa2l/blob/46b8494c2ad4429bbe1042b6e87b139dd7422c31/fa2l/force.py#L17-L22
train
ergo/ziggurat_foundations
ziggurat_foundations/models/services/external_identity.py
ExternalIdentityService.get
def get(cls, external_id, local_user_id, provider_name, db_session=None): """ Fetch row using primary key - will use existing object in session if already present :param external_id: :param local_user_id: :param provider_name: :param db_session: :return: ...
python
def get(cls, external_id, local_user_id, provider_name, db_session=None): """ Fetch row using primary key - will use existing object in session if already present :param external_id: :param local_user_id: :param provider_name: :param db_session: :return: ...
[ "def", "get", "(", "cls", ",", "external_id", ",", "local_user_id", ",", "provider_name", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "return", "db_session", ".", "query", "(", "cls", ".", "model", ...
Fetch row using primary key - will use existing object in session if already present :param external_id: :param local_user_id: :param provider_name: :param db_session: :return:
[ "Fetch", "row", "using", "primary", "key", "-", "will", "use", "existing", "object", "in", "session", "if", "already", "present" ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/external_identity.py#L12-L26
train
ergo/ziggurat_foundations
ziggurat_foundations/models/services/external_identity.py
ExternalIdentityService.by_external_id_and_provider
def by_external_id_and_provider(cls, external_id, provider_name, db_session=None): """ Returns ExternalIdentity instance based on search params :param external_id: :param provider_name: :param db_session: :return: ExternalIdentity """ db_session = get_db_...
python
def by_external_id_and_provider(cls, external_id, provider_name, db_session=None): """ Returns ExternalIdentity instance based on search params :param external_id: :param provider_name: :param db_session: :return: ExternalIdentity """ db_session = get_db_...
[ "def", "by_external_id_and_provider", "(", "cls", ",", "external_id", ",", "provider_name", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "model...
Returns ExternalIdentity instance based on search params :param external_id: :param provider_name: :param db_session: :return: ExternalIdentity
[ "Returns", "ExternalIdentity", "instance", "based", "on", "search", "params" ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/external_identity.py#L29-L42
train
ergo/ziggurat_foundations
ziggurat_foundations/models/services/external_identity.py
ExternalIdentityService.user_by_external_id_and_provider
def user_by_external_id_and_provider( cls, external_id, provider_name, db_session=None ): """ Returns User instance based on search params :param external_id: :param provider_name: :param db_session: :return: User """ db_session = get_db_sessi...
python
def user_by_external_id_and_provider( cls, external_id, provider_name, db_session=None ): """ Returns User instance based on search params :param external_id: :param provider_name: :param db_session: :return: User """ db_session = get_db_sessi...
[ "def", "user_by_external_id_and_provider", "(", "cls", ",", "external_id", ",", "provider_name", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "...
Returns User instance based on search params :param external_id: :param provider_name: :param db_session: :return: User
[ "Returns", "User", "instance", "based", "on", "search", "params" ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/external_identity.py#L45-L61
train
ergo/ziggurat_foundations
ziggurat_foundations/models/services/user_permission.py
UserPermissionService.by_user_and_perm
def by_user_and_perm(cls, user_id, perm_name, db_session=None): """ return by user and permission name :param user_id: :param perm_name: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.query(cls.model).fi...
python
def by_user_and_perm(cls, user_id, perm_name, db_session=None): """ return by user and permission name :param user_id: :param perm_name: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.query(cls.model).fi...
[ "def", "by_user_and_perm", "(", "cls", ",", "user_id", ",", "perm_name", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "model", ")", ".", ...
return by user and permission name :param user_id: :param perm_name: :param db_session: :return:
[ "return", "by", "user", "and", "permission", "name" ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user_permission.py#L26-L38
train
jucacrispim/pylint-mongoengine
pylint_mongoengine/utils.py
node_is_subclass
def node_is_subclass(cls, *subclass_names): """Checks if cls node has parent with subclass_name.""" if not isinstance(cls, (ClassDef, Instance)): return False # if cls.bases == YES: # return False for base_cls in cls.bases: try: for inf in base_cls.inferred(): # pra...
python
def node_is_subclass(cls, *subclass_names): """Checks if cls node has parent with subclass_name.""" if not isinstance(cls, (ClassDef, Instance)): return False # if cls.bases == YES: # return False for base_cls in cls.bases: try: for inf in base_cls.inferred(): # pra...
[ "def", "node_is_subclass", "(", "cls", ",", "*", "subclass_names", ")", ":", "if", "not", "isinstance", "(", "cls", ",", "(", "ClassDef", ",", "Instance", ")", ")", ":", "return", "False", "# if cls.bases == YES:", "# return False", "for", "base_cls", "in"...
Checks if cls node has parent with subclass_name.
[ "Checks", "if", "cls", "node", "has", "parent", "with", "subclass_name", "." ]
b873653d1224a5748f75dd507f492f8c60d95ce3
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L39-L60
train
jucacrispim/pylint-mongoengine
pylint_mongoengine/utils.py
is_field_method
def is_field_method(node): """Checks if a call to a field instance method is valid. A call is valid if the call is a method of the underlying type. So, in a StringField the methods from str are valid, in a ListField the methods from list are valid and so on...""" name = node.attrname parent = no...
python
def is_field_method(node): """Checks if a call to a field instance method is valid. A call is valid if the call is a method of the underlying type. So, in a StringField the methods from str are valid, in a ListField the methods from list are valid and so on...""" name = node.attrname parent = no...
[ "def", "is_field_method", "(", "node", ")", ":", "name", "=", "node", ".", "attrname", "parent", "=", "node", ".", "last_child", "(", ")", "inferred", "=", "safe_infer", "(", "parent", ")", "if", "not", "inferred", ":", "return", "False", "for", "cls_nam...
Checks if a call to a field instance method is valid. A call is valid if the call is a method of the underlying type. So, in a StringField the methods from str are valid, in a ListField the methods from list are valid and so on...
[ "Checks", "if", "a", "call", "to", "a", "field", "instance", "method", "is", "valid", ".", "A", "call", "is", "valid", "if", "the", "call", "is", "a", "method", "of", "the", "underlying", "type", ".", "So", "in", "a", "StringField", "the", "methods", ...
b873653d1224a5748f75dd507f492f8c60d95ce3
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L83-L99
train
jucacrispim/pylint-mongoengine
pylint_mongoengine/utils.py
get_node_parent_class
def get_node_parent_class(node): """Supposes that node is a mongoengine field in a class and tries to get its parent class""" while node.parent: # pragma no branch if isinstance(node, ClassDef): return node node = node.parent
python
def get_node_parent_class(node): """Supposes that node is a mongoengine field in a class and tries to get its parent class""" while node.parent: # pragma no branch if isinstance(node, ClassDef): return node node = node.parent
[ "def", "get_node_parent_class", "(", "node", ")", ":", "while", "node", ".", "parent", ":", "# pragma no branch", "if", "isinstance", "(", "node", ",", "ClassDef", ")", ":", "return", "node", "node", "=", "node", ".", "parent" ]
Supposes that node is a mongoengine field in a class and tries to get its parent class
[ "Supposes", "that", "node", "is", "a", "mongoengine", "field", "in", "a", "class", "and", "tries", "to", "get", "its", "parent", "class" ]
b873653d1224a5748f75dd507f492f8c60d95ce3
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L102-L110
train
jucacrispim/pylint-mongoengine
pylint_mongoengine/utils.py
get_field_definition
def get_field_definition(node): """"node is a class attribute that is a mongoengine. Returns the definition statement for the attribute """ name = node.attrname cls = get_node_parent_class(node) definition = cls.lookup(name)[1][0].statement() return definition
python
def get_field_definition(node): """"node is a class attribute that is a mongoengine. Returns the definition statement for the attribute """ name = node.attrname cls = get_node_parent_class(node) definition = cls.lookup(name)[1][0].statement() return definition
[ "def", "get_field_definition", "(", "node", ")", ":", "name", "=", "node", ".", "attrname", "cls", "=", "get_node_parent_class", "(", "node", ")", "definition", "=", "cls", ".", "lookup", "(", "name", ")", "[", "1", "]", "[", "0", "]", ".", "statement"...
node is a class attribute that is a mongoengine. Returns the definition statement for the attribute
[ "node", "is", "a", "class", "attribute", "that", "is", "a", "mongoengine", ".", "Returns", "the", "definition", "statement", "for", "the", "attribute" ]
b873653d1224a5748f75dd507f492f8c60d95ce3
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L122-L130
train
jucacrispim/pylint-mongoengine
pylint_mongoengine/utils.py
get_field_embedded_doc
def get_field_embedded_doc(node): """Returns de ClassDef for the related embedded document in a embedded document field.""" definition = get_field_definition(node) cls_name = definition.last_child().last_child() cls = next(cls_name.infer()) return cls
python
def get_field_embedded_doc(node): """Returns de ClassDef for the related embedded document in a embedded document field.""" definition = get_field_definition(node) cls_name = definition.last_child().last_child() cls = next(cls_name.infer()) return cls
[ "def", "get_field_embedded_doc", "(", "node", ")", ":", "definition", "=", "get_field_definition", "(", "node", ")", "cls_name", "=", "definition", ".", "last_child", "(", ")", ".", "last_child", "(", ")", "cls", "=", "next", "(", "cls_name", ".", "infer", ...
Returns de ClassDef for the related embedded document in a embedded document field.
[ "Returns", "de", "ClassDef", "for", "the", "related", "embedded", "document", "in", "a", "embedded", "document", "field", "." ]
b873653d1224a5748f75dd507f492f8c60d95ce3
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L133-L140
train
jucacrispim/pylint-mongoengine
pylint_mongoengine/utils.py
node_is_embedded_doc_attr
def node_is_embedded_doc_attr(node): """Checks if a node is a valid field or method in a embedded document. """ embedded_doc = get_field_embedded_doc(node.last_child()) name = node.attrname try: r = bool(embedded_doc.lookup(name)[1][0]) except IndexError: r = False return r
python
def node_is_embedded_doc_attr(node): """Checks if a node is a valid field or method in a embedded document. """ embedded_doc = get_field_embedded_doc(node.last_child()) name = node.attrname try: r = bool(embedded_doc.lookup(name)[1][0]) except IndexError: r = False return r
[ "def", "node_is_embedded_doc_attr", "(", "node", ")", ":", "embedded_doc", "=", "get_field_embedded_doc", "(", "node", ".", "last_child", "(", ")", ")", "name", "=", "node", ".", "attrname", "try", ":", "r", "=", "bool", "(", "embedded_doc", ".", "lookup", ...
Checks if a node is a valid field or method in a embedded document.
[ "Checks", "if", "a", "node", "is", "a", "valid", "field", "or", "method", "in", "a", "embedded", "document", "." ]
b873653d1224a5748f75dd507f492f8c60d95ce3
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L143-L153
train
stephenmcd/gnotty
gnotty/bots/base.py
BaseBot._dispatcher
def _dispatcher(self, connection, event): """ This is the method in ``SimpleIRCClient`` that all IRC events get passed through. Here we map events to our own custom event handlers, and call them. """ super(BaseBot, self)._dispatcher(connection, event) for handler ...
python
def _dispatcher(self, connection, event): """ This is the method in ``SimpleIRCClient`` that all IRC events get passed through. Here we map events to our own custom event handlers, and call them. """ super(BaseBot, self)._dispatcher(connection, event) for handler ...
[ "def", "_dispatcher", "(", "self", ",", "connection", ",", "event", ")", ":", "super", "(", "BaseBot", ",", "self", ")", ".", "_dispatcher", "(", "connection", ",", "event", ")", "for", "handler", "in", "self", ".", "events", "[", "event", ".", "eventt...
This is the method in ``SimpleIRCClient`` that all IRC events get passed through. Here we map events to our own custom event handlers, and call them.
[ "This", "is", "the", "method", "in", "SimpleIRCClient", "that", "all", "IRC", "events", "get", "passed", "through", ".", "Here", "we", "map", "events", "to", "our", "own", "custom", "event", "handlers", "and", "call", "them", "." ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L57-L65
train
stephenmcd/gnotty
gnotty/bots/base.py
BaseBot.message_channel
def message_channel(self, message): """ We won't receive our own messages, so log them manually. """ self.log(None, message) super(BaseBot, self).message_channel(message)
python
def message_channel(self, message): """ We won't receive our own messages, so log them manually. """ self.log(None, message) super(BaseBot, self).message_channel(message)
[ "def", "message_channel", "(", "self", ",", "message", ")", ":", "self", ".", "log", "(", "None", ",", "message", ")", "super", "(", "BaseBot", ",", "self", ")", ".", "message_channel", "(", "message", ")" ]
We won't receive our own messages, so log them manually.
[ "We", "won", "t", "receive", "our", "own", "messages", "so", "log", "them", "manually", "." ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L76-L81
train
stephenmcd/gnotty
gnotty/bots/base.py
BaseBot.on_pubmsg
def on_pubmsg(self, connection, event): """ Log any public messages, and also handle the command event. """ for message in event.arguments(): self.log(event, message) command_args = filter(None, message.split()) command_name = command_args.pop(0) ...
python
def on_pubmsg(self, connection, event): """ Log any public messages, and also handle the command event. """ for message in event.arguments(): self.log(event, message) command_args = filter(None, message.split()) command_name = command_args.pop(0) ...
[ "def", "on_pubmsg", "(", "self", ",", "connection", ",", "event", ")", ":", "for", "message", "in", "event", ".", "arguments", "(", ")", ":", "self", ".", "log", "(", "event", ",", "message", ")", "command_args", "=", "filter", "(", "None", ",", "mes...
Log any public messages, and also handle the command event.
[ "Log", "any", "public", "messages", "and", "also", "handle", "the", "command", "event", "." ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L92-L102
train
stephenmcd/gnotty
gnotty/bots/base.py
BaseBot.handle_command_event
def handle_command_event(self, event, command, args): """ Command handler - treats each word in the message that triggered the command as an argument to the command, and does some validation to ensure that the number of arguments match. """ argspec = getargspec(co...
python
def handle_command_event(self, event, command, args): """ Command handler - treats each word in the message that triggered the command as an argument to the command, and does some validation to ensure that the number of arguments match. """ argspec = getargspec(co...
[ "def", "handle_command_event", "(", "self", ",", "event", ",", "command", ",", "args", ")", ":", "argspec", "=", "getargspec", "(", "command", ")", "num_all_args", "=", "len", "(", "argspec", ".", "args", ")", "-", "2", "# Ignore self/event args", "num_pos_a...
Command handler - treats each word in the message that triggered the command as an argument to the command, and does some validation to ensure that the number of arguments match.
[ "Command", "handler", "-", "treats", "each", "word", "in", "the", "message", "that", "triggered", "the", "command", "as", "an", "argument", "to", "the", "command", "and", "does", "some", "validation", "to", "ensure", "that", "the", "number", "of", "arguments...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L104-L123
train
stephenmcd/gnotty
gnotty/bots/base.py
BaseBot.handle_timer_event
def handle_timer_event(self, handler): """ Runs each timer handler in a separate greenlet thread. """ while True: handler(self) sleep(handler.event.args["seconds"])
python
def handle_timer_event(self, handler): """ Runs each timer handler in a separate greenlet thread. """ while True: handler(self) sleep(handler.event.args["seconds"])
[ "def", "handle_timer_event", "(", "self", ",", "handler", ")", ":", "while", "True", ":", "handler", "(", "self", ")", "sleep", "(", "handler", ".", "event", ".", "args", "[", "\"seconds\"", "]", ")" ]
Runs each timer handler in a separate greenlet thread.
[ "Runs", "each", "timer", "handler", "in", "a", "separate", "greenlet", "thread", "." ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L125-L131
train
stephenmcd/gnotty
gnotty/bots/base.py
BaseBot.handle_webhook_event
def handle_webhook_event(self, environ, url, params): """ Webhook handler - each handler for the webhook event takes an initial pattern argument for matching the URL requested. Here we match the URL to the pattern for each webhook handler, and bail out if it returns a response. ...
python
def handle_webhook_event(self, environ, url, params): """ Webhook handler - each handler for the webhook event takes an initial pattern argument for matching the URL requested. Here we match the URL to the pattern for each webhook handler, and bail out if it returns a response. ...
[ "def", "handle_webhook_event", "(", "self", ",", "environ", ",", "url", ",", "params", ")", ":", "for", "handler", "in", "self", ".", "events", "[", "\"webhook\"", "]", ":", "urlpattern", "=", "handler", ".", "event", ".", "args", "[", "\"urlpattern\"", ...
Webhook handler - each handler for the webhook event takes an initial pattern argument for matching the URL requested. Here we match the URL to the pattern for each webhook handler, and bail out if it returns a response.
[ "Webhook", "handler", "-", "each", "handler", "for", "the", "webhook", "event", "takes", "an", "initial", "pattern", "argument", "for", "matching", "the", "URL", "requested", ".", "Here", "we", "match", "the", "URL", "to", "the", "pattern", "for", "each", ...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L133-L145
train
erijo/tellcore-py
tellcore/telldus.py
DeviceFactory
def DeviceFactory(id, lib=None): """Create the correct device instance based on device type and return it. :return: a :class:`Device` or :class:`DeviceGroup` instance. """ lib = lib or Library() if lib.tdGetDeviceType(id) == const.TELLSTICK_TYPE_GROUP: return DeviceGroup(id, lib=lib) re...
python
def DeviceFactory(id, lib=None): """Create the correct device instance based on device type and return it. :return: a :class:`Device` or :class:`DeviceGroup` instance. """ lib = lib or Library() if lib.tdGetDeviceType(id) == const.TELLSTICK_TYPE_GROUP: return DeviceGroup(id, lib=lib) re...
[ "def", "DeviceFactory", "(", "id", ",", "lib", "=", "None", ")", ":", "lib", "=", "lib", "or", "Library", "(", ")", "if", "lib", ".", "tdGetDeviceType", "(", "id", ")", "==", "const", ".", "TELLSTICK_TYPE_GROUP", ":", "return", "DeviceGroup", "(", "id"...
Create the correct device instance based on device type and return it. :return: a :class:`Device` or :class:`DeviceGroup` instance.
[ "Create", "the", "correct", "device", "instance", "based", "on", "device", "type", "and", "return", "it", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L266-L274
train
erijo/tellcore-py
tellcore/telldus.py
QueuedCallbackDispatcher.process_callback
def process_callback(self, block=True): """Dispatch a single callback in the current thread. :param boolean block: If True, blocks waiting for a callback to come. :return: True if a callback was processed; otherwise False. """ try: (callback, args) = self._queue.get(...
python
def process_callback(self, block=True): """Dispatch a single callback in the current thread. :param boolean block: If True, blocks waiting for a callback to come. :return: True if a callback was processed; otherwise False. """ try: (callback, args) = self._queue.get(...
[ "def", "process_callback", "(", "self", ",", "block", "=", "True", ")", ":", "try", ":", "(", "callback", ",", "args", ")", "=", "self", ".", "_queue", ".", "get", "(", "block", "=", "block", ")", "try", ":", "callback", "(", "*", "args", ")", "f...
Dispatch a single callback in the current thread. :param boolean block: If True, blocks waiting for a callback to come. :return: True if a callback was processed; otherwise False.
[ "Dispatch", "a", "single", "callback", "in", "the", "current", "thread", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L48-L62
train
erijo/tellcore-py
tellcore/telldus.py
TelldusCore.devices
def devices(self): """Return all known devices. :return: list of :class:`Device` or :class:`DeviceGroup` instances. """ devices = [] count = self.lib.tdGetNumberOfDevices() for i in range(count): device = DeviceFactory(self.lib.tdGetDeviceId(i), lib=self.lib)...
python
def devices(self): """Return all known devices. :return: list of :class:`Device` or :class:`DeviceGroup` instances. """ devices = [] count = self.lib.tdGetNumberOfDevices() for i in range(count): device = DeviceFactory(self.lib.tdGetDeviceId(i), lib=self.lib)...
[ "def", "devices", "(", "self", ")", ":", "devices", "=", "[", "]", "count", "=", "self", ".", "lib", ".", "tdGetNumberOfDevices", "(", ")", "for", "i", "in", "range", "(", "count", ")", ":", "device", "=", "DeviceFactory", "(", "self", ".", "lib", ...
Return all known devices. :return: list of :class:`Device` or :class:`DeviceGroup` instances.
[ "Return", "all", "known", "devices", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L169-L179
train
erijo/tellcore-py
tellcore/telldus.py
TelldusCore.sensors
def sensors(self): """Return all known sensors. :return: list of :class:`Sensor` instances. """ sensors = [] try: while True: sensor = self.lib.tdSensor() sensors.append(Sensor(lib=self.lib, **sensor)) except TelldusError as e:...
python
def sensors(self): """Return all known sensors. :return: list of :class:`Sensor` instances. """ sensors = [] try: while True: sensor = self.lib.tdSensor() sensors.append(Sensor(lib=self.lib, **sensor)) except TelldusError as e:...
[ "def", "sensors", "(", "self", ")", ":", "sensors", "=", "[", "]", "try", ":", "while", "True", ":", "sensor", "=", "self", ".", "lib", ".", "tdSensor", "(", ")", "sensors", ".", "append", "(", "Sensor", "(", "lib", "=", "self", ".", "lib", ",", ...
Return all known sensors. :return: list of :class:`Sensor` instances.
[ "Return", "all", "known", "sensors", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L181-L194
train
erijo/tellcore-py
tellcore/telldus.py
TelldusCore.controllers
def controllers(self): """Return all known controllers. Requires Telldus core library version >= 2.1.2. :return: list of :class:`Controller` instances. """ controllers = [] try: while True: controller = self.lib.tdController() ...
python
def controllers(self): """Return all known controllers. Requires Telldus core library version >= 2.1.2. :return: list of :class:`Controller` instances. """ controllers = [] try: while True: controller = self.lib.tdController() ...
[ "def", "controllers", "(", "self", ")", ":", "controllers", "=", "[", "]", "try", ":", "while", "True", ":", "controller", "=", "self", ".", "lib", ".", "tdController", "(", ")", "del", "controller", "[", "\"name\"", "]", "del", "controller", "[", "\"a...
Return all known controllers. Requires Telldus core library version >= 2.1.2. :return: list of :class:`Controller` instances.
[ "Return", "all", "known", "controllers", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L196-L213
train
erijo/tellcore-py
tellcore/telldus.py
TelldusCore.add_device
def add_device(self, name, protocol, model=None, **parameters): """Add a new device. :return: a :class:`Device` or :class:`DeviceGroup` instance. """ device = Device(self.lib.tdAddDevice(), lib=self.lib) try: device.name = name device.protocol = protocol ...
python
def add_device(self, name, protocol, model=None, **parameters): """Add a new device. :return: a :class:`Device` or :class:`DeviceGroup` instance. """ device = Device(self.lib.tdAddDevice(), lib=self.lib) try: device.name = name device.protocol = protocol ...
[ "def", "add_device", "(", "self", ",", "name", ",", "protocol", ",", "model", "=", "None", ",", "*", "*", "parameters", ")", ":", "device", "=", "Device", "(", "self", ".", "lib", ".", "tdAddDevice", "(", ")", ",", "lib", "=", "self", ".", "lib", ...
Add a new device. :return: a :class:`Device` or :class:`DeviceGroup` instance.
[ "Add", "a", "new", "device", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L215-L242
train
erijo/tellcore-py
tellcore/telldus.py
TelldusCore.add_group
def add_group(self, name, devices): """Add a new device group. :return: a :class:`DeviceGroup` instance. """ device = self.add_device(name, "group") device.add_to_group(devices) return device
python
def add_group(self, name, devices): """Add a new device group. :return: a :class:`DeviceGroup` instance. """ device = self.add_device(name, "group") device.add_to_group(devices) return device
[ "def", "add_group", "(", "self", ",", "name", ",", "devices", ")", ":", "device", "=", "self", ".", "add_device", "(", "name", ",", "\"group\"", ")", "device", ".", "add_to_group", "(", "devices", ")", "return", "device" ]
Add a new device group. :return: a :class:`DeviceGroup` instance.
[ "Add", "a", "new", "device", "group", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L244-L251
train
erijo/tellcore-py
tellcore/telldus.py
TelldusCore.connect_controller
def connect_controller(self, vid, pid, serial): """Connect a controller.""" self.lib.tdConnectTellStickController(vid, pid, serial)
python
def connect_controller(self, vid, pid, serial): """Connect a controller.""" self.lib.tdConnectTellStickController(vid, pid, serial)
[ "def", "connect_controller", "(", "self", ",", "vid", ",", "pid", ",", "serial", ")", ":", "self", ".", "lib", ".", "tdConnectTellStickController", "(", "vid", ",", "pid", ",", "serial", ")" ]
Connect a controller.
[ "Connect", "a", "controller", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L257-L259
train
erijo/tellcore-py
tellcore/telldus.py
TelldusCore.disconnect_controller
def disconnect_controller(self, vid, pid, serial): """Disconnect a controller.""" self.lib.tdDisconnectTellStickController(vid, pid, serial)
python
def disconnect_controller(self, vid, pid, serial): """Disconnect a controller.""" self.lib.tdDisconnectTellStickController(vid, pid, serial)
[ "def", "disconnect_controller", "(", "self", ",", "vid", ",", "pid", ",", "serial", ")", ":", "self", ".", "lib", ".", "tdDisconnectTellStickController", "(", "vid", ",", "pid", ",", "serial", ")" ]
Disconnect a controller.
[ "Disconnect", "a", "controller", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L261-L263
train
erijo/tellcore-py
tellcore/telldus.py
Device.parameters
def parameters(self): """Get dict with all set parameters.""" parameters = {} for name in self.PARAMETERS: try: parameters[name] = self.get_parameter(name) except AttributeError: pass return parameters
python
def parameters(self): """Get dict with all set parameters.""" parameters = {} for name in self.PARAMETERS: try: parameters[name] = self.get_parameter(name) except AttributeError: pass return parameters
[ "def", "parameters", "(", "self", ")", ":", "parameters", "=", "{", "}", "for", "name", "in", "self", ".", "PARAMETERS", ":", "try", ":", "parameters", "[", "name", "]", "=", "self", ".", "get_parameter", "(", "name", ")", "except", "AttributeError", "...
Get dict with all set parameters.
[ "Get", "dict", "with", "all", "set", "parameters", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L323-L331
train
erijo/tellcore-py
tellcore/telldus.py
Device.get_parameter
def get_parameter(self, name): """Get a parameter.""" default_value = "$%!)(INVALID)(!%$" value = self.lib.tdGetDeviceParameter(self.id, name, default_value) if value == default_value: raise AttributeError(name) return value
python
def get_parameter(self, name): """Get a parameter.""" default_value = "$%!)(INVALID)(!%$" value = self.lib.tdGetDeviceParameter(self.id, name, default_value) if value == default_value: raise AttributeError(name) return value
[ "def", "get_parameter", "(", "self", ",", "name", ")", ":", "default_value", "=", "\"$%!)(INVALID)(!%$\"", "value", "=", "self", ".", "lib", ".", "tdGetDeviceParameter", "(", "self", ".", "id", ",", "name", ",", "default_value", ")", "if", "value", "==", "...
Get a parameter.
[ "Get", "a", "parameter", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L333-L339
train
erijo/tellcore-py
tellcore/telldus.py
Device.set_parameter
def set_parameter(self, name, value): """Set a parameter.""" self.lib.tdSetDeviceParameter(self.id, name, str(value))
python
def set_parameter(self, name, value): """Set a parameter.""" self.lib.tdSetDeviceParameter(self.id, name, str(value))
[ "def", "set_parameter", "(", "self", ",", "name", ",", "value", ")", ":", "self", ".", "lib", ".", "tdSetDeviceParameter", "(", "self", ".", "id", ",", "name", ",", "str", "(", "value", ")", ")" ]
Set a parameter.
[ "Set", "a", "parameter", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L341-L343
train
erijo/tellcore-py
tellcore/telldus.py
DeviceGroup.add_to_group
def add_to_group(self, devices): """Add device(s) to the group.""" ids = {d.id for d in self.devices_in_group()} ids.update(self._device_ids(devices)) self._set_group(ids)
python
def add_to_group(self, devices): """Add device(s) to the group.""" ids = {d.id for d in self.devices_in_group()} ids.update(self._device_ids(devices)) self._set_group(ids)
[ "def", "add_to_group", "(", "self", ",", "devices", ")", ":", "ids", "=", "{", "d", ".", "id", "for", "d", "in", "self", ".", "devices_in_group", "(", ")", "}", "ids", ".", "update", "(", "self", ".", "_device_ids", "(", "devices", ")", ")", "self"...
Add device(s) to the group.
[ "Add", "device", "(", "s", ")", "to", "the", "group", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L406-L410
train
erijo/tellcore-py
tellcore/telldus.py
DeviceGroup.remove_from_group
def remove_from_group(self, devices): """Remove device(s) from the group.""" ids = {d.id for d in self.devices_in_group()} ids.difference_update(self._device_ids(devices)) self._set_group(ids)
python
def remove_from_group(self, devices): """Remove device(s) from the group.""" ids = {d.id for d in self.devices_in_group()} ids.difference_update(self._device_ids(devices)) self._set_group(ids)
[ "def", "remove_from_group", "(", "self", ",", "devices", ")", ":", "ids", "=", "{", "d", ".", "id", "for", "d", "in", "self", ".", "devices_in_group", "(", ")", "}", "ids", ".", "difference_update", "(", "self", ".", "_device_ids", "(", "devices", ")",...
Remove device(s) from the group.
[ "Remove", "device", "(", "s", ")", "from", "the", "group", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L412-L416
train
erijo/tellcore-py
tellcore/telldus.py
DeviceGroup.devices_in_group
def devices_in_group(self): """Fetch list of devices in group.""" try: devices = self.get_parameter('devices') except AttributeError: return [] ctor = DeviceFactory return [ctor(int(x), lib=self.lib) for x in devices.split(',') if x]
python
def devices_in_group(self): """Fetch list of devices in group.""" try: devices = self.get_parameter('devices') except AttributeError: return [] ctor = DeviceFactory return [ctor(int(x), lib=self.lib) for x in devices.split(',') if x]
[ "def", "devices_in_group", "(", "self", ")", ":", "try", ":", "devices", "=", "self", ".", "get_parameter", "(", "'devices'", ")", "except", "AttributeError", ":", "return", "[", "]", "ctor", "=", "DeviceFactory", "return", "[", "ctor", "(", "int", "(", ...
Fetch list of devices in group.
[ "Fetch", "list", "of", "devices", "in", "group", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L418-L426
train
erijo/tellcore-py
tellcore/telldus.py
Sensor.value
def value(self, datatype): """Return the :class:`SensorValue` for the given data type. sensor.value(TELLSTICK_TEMPERATURE) is identical to calling sensor.temperature(). """ value = self.lib.tdSensorValue( self.protocol, self.model, self.id, datatype) return S...
python
def value(self, datatype): """Return the :class:`SensorValue` for the given data type. sensor.value(TELLSTICK_TEMPERATURE) is identical to calling sensor.temperature(). """ value = self.lib.tdSensorValue( self.protocol, self.model, self.id, datatype) return S...
[ "def", "value", "(", "self", ",", "datatype", ")", ":", "value", "=", "self", ".", "lib", ".", "tdSensorValue", "(", "self", ".", "protocol", ",", "self", ".", "model", ",", "self", ".", "id", ",", "datatype", ")", "return", "SensorValue", "(", "data...
Return the :class:`SensorValue` for the given data type. sensor.value(TELLSTICK_TEMPERATURE) is identical to calling sensor.temperature().
[ "Return", "the", ":", "class", ":", "SensorValue", "for", "the", "given", "data", "type", "." ]
7a1eb53e12ef039a2350933e502633df7560f6a8
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L478-L486
train
typemytype/booleanOperations
Lib/booleanOperations/flatten.py
_prepPointsForSegments
def _prepPointsForSegments(points): """ Move any off curves at the end of the contour to the beginning of the contour. This makes segmentation easier. """ while 1: point = points[-1] if point.segmentType: break else: point = points.pop() ...
python
def _prepPointsForSegments(points): """ Move any off curves at the end of the contour to the beginning of the contour. This makes segmentation easier. """ while 1: point = points[-1] if point.segmentType: break else: point = points.pop() ...
[ "def", "_prepPointsForSegments", "(", "points", ")", ":", "while", "1", ":", "point", "=", "points", "[", "-", "1", "]", "if", "point", ".", "segmentType", ":", "break", "else", ":", "point", "=", "points", ".", "pop", "(", ")", "points", ".", "inser...
Move any off curves at the end of the contour to the beginning of the contour. This makes segmentation easier.
[ "Move", "any", "off", "curves", "at", "the", "end", "of", "the", "contour", "to", "the", "beginning", "of", "the", "contour", ".", "This", "makes", "segmentation", "easier", "." ]
b7d9fc95c155824662f4a0020e653c77b7723d24
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L360-L374
train
typemytype/booleanOperations
Lib/booleanOperations/flatten.py
_reversePoints
def _reversePoints(points): """ Reverse the points. This differs from the reversal point pen in RoboFab in that it doesn't worry about maintaing the start point position. That has no benefit within the context of this module. """ # copy the points points = _copyPoints(points) # find ...
python
def _reversePoints(points): """ Reverse the points. This differs from the reversal point pen in RoboFab in that it doesn't worry about maintaing the start point position. That has no benefit within the context of this module. """ # copy the points points = _copyPoints(points) # find ...
[ "def", "_reversePoints", "(", "points", ")", ":", "# copy the points", "points", "=", "_copyPoints", "(", "points", ")", "# find the first on curve type and recycle", "# it for the last on curve type", "firstOnCurve", "=", "None", "for", "index", ",", "point", "in", "en...
Reverse the points. This differs from the reversal point pen in RoboFab in that it doesn't worry about maintaing the start point position. That has no benefit within the context of this module.
[ "Reverse", "the", "points", ".", "This", "differs", "from", "the", "reversal", "point", "pen", "in", "RoboFab", "in", "that", "it", "doesn", "t", "worry", "about", "maintaing", "the", "start", "point", "position", ".", "That", "has", "no", "benefit", "with...
b7d9fc95c155824662f4a0020e653c77b7723d24
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L385-L416
train
typemytype/booleanOperations
Lib/booleanOperations/flatten.py
_convertPointsToSegments
def _convertPointsToSegments(points, willBeReversed=False): """ Compile points into InputSegment objects. """ # get the last on curve previousOnCurve = None for point in reversed(points): if point.segmentType is not None: previousOnCurve = point.coordinates break ...
python
def _convertPointsToSegments(points, willBeReversed=False): """ Compile points into InputSegment objects. """ # get the last on curve previousOnCurve = None for point in reversed(points): if point.segmentType is not None: previousOnCurve = point.coordinates break ...
[ "def", "_convertPointsToSegments", "(", "points", ",", "willBeReversed", "=", "False", ")", ":", "# get the last on curve", "previousOnCurve", "=", "None", "for", "point", "in", "reversed", "(", "points", ")", ":", "if", "point", ".", "segmentType", "is", "not",...
Compile points into InputSegment objects.
[ "Compile", "points", "into", "InputSegment", "objects", "." ]
b7d9fc95c155824662f4a0020e653c77b7723d24
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L419-L447
train
typemytype/booleanOperations
Lib/booleanOperations/flatten.py
_tValueForPointOnCubicCurve
def _tValueForPointOnCubicCurve(point, cubicCurve, isHorizontal=0): """ Finds a t value on a curve from a point. The points must be originaly be a point on the curve. This will only back trace the t value, needed to split the curve in parts """ pt1, pt2, pt3, pt4 = cubicCurve a, b, c, d = be...
python
def _tValueForPointOnCubicCurve(point, cubicCurve, isHorizontal=0): """ Finds a t value on a curve from a point. The points must be originaly be a point on the curve. This will only back trace the t value, needed to split the curve in parts """ pt1, pt2, pt3, pt4 = cubicCurve a, b, c, d = be...
[ "def", "_tValueForPointOnCubicCurve", "(", "point", ",", "cubicCurve", ",", "isHorizontal", "=", "0", ")", ":", "pt1", ",", "pt2", ",", "pt3", ",", "pt4", "=", "cubicCurve", "a", ",", "b", ",", "c", ",", "d", "=", "bezierTools", ".", "calcCubicParameters...
Finds a t value on a curve from a point. The points must be originaly be a point on the curve. This will only back trace the t value, needed to split the curve in parts
[ "Finds", "a", "t", "value", "on", "a", "curve", "from", "a", "point", ".", "The", "points", "must", "be", "originaly", "be", "a", "point", "on", "the", "curve", ".", "This", "will", "only", "back", "trace", "the", "t", "value", "needed", "to", "split...
b7d9fc95c155824662f4a0020e653c77b7723d24
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L950-L972
train
typemytype/booleanOperations
Lib/booleanOperations/flatten.py
_scalePoints
def _scalePoints(points, scale=1, convertToInteger=True): """ Scale points and optionally convert them to integers. """ if convertToInteger: points = [ (int(round(x * scale)), int(round(y * scale))) for (x, y) in points ] else: points = [(x * scale, y ...
python
def _scalePoints(points, scale=1, convertToInteger=True): """ Scale points and optionally convert them to integers. """ if convertToInteger: points = [ (int(round(x * scale)), int(round(y * scale))) for (x, y) in points ] else: points = [(x * scale, y ...
[ "def", "_scalePoints", "(", "points", ",", "scale", "=", "1", ",", "convertToInteger", "=", "True", ")", ":", "if", "convertToInteger", ":", "points", "=", "[", "(", "int", "(", "round", "(", "x", "*", "scale", ")", ")", ",", "int", "(", "round", "...
Scale points and optionally convert them to integers.
[ "Scale", "points", "and", "optionally", "convert", "them", "to", "integers", "." ]
b7d9fc95c155824662f4a0020e653c77b7723d24
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L1007-L1018
train
typemytype/booleanOperations
Lib/booleanOperations/flatten.py
_scaleSinglePoint
def _scaleSinglePoint(point, scale=1, convertToInteger=True): """ Scale a single point """ x, y = point if convertToInteger: return int(round(x * scale)), int(round(y * scale)) else: return (x * scale, y * scale)
python
def _scaleSinglePoint(point, scale=1, convertToInteger=True): """ Scale a single point """ x, y = point if convertToInteger: return int(round(x * scale)), int(round(y * scale)) else: return (x * scale, y * scale)
[ "def", "_scaleSinglePoint", "(", "point", ",", "scale", "=", "1", ",", "convertToInteger", "=", "True", ")", ":", "x", ",", "y", "=", "point", "if", "convertToInteger", ":", "return", "int", "(", "round", "(", "x", "*", "scale", ")", ")", ",", "int",...
Scale a single point
[ "Scale", "a", "single", "point" ]
b7d9fc95c155824662f4a0020e653c77b7723d24
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L1021-L1029
train
typemytype/booleanOperations
Lib/booleanOperations/flatten.py
_flattenSegment
def _flattenSegment(segment, approximateSegmentLength=_approximateSegmentLength): """ Flatten the curve segment int a list of points. The first and last points in the segment must be on curves. The returned list of points will not include the first on curve point. false curves (where the off cur...
python
def _flattenSegment(segment, approximateSegmentLength=_approximateSegmentLength): """ Flatten the curve segment int a list of points. The first and last points in the segment must be on curves. The returned list of points will not include the first on curve point. false curves (where the off cur...
[ "def", "_flattenSegment", "(", "segment", ",", "approximateSegmentLength", "=", "_approximateSegmentLength", ")", ":", "onCurve1", ",", "offCurve1", ",", "offCurve2", ",", "onCurve2", "=", "segment", "if", "_pointOnLine", "(", "onCurve1", ",", "onCurve2", ",", "of...
Flatten the curve segment int a list of points. The first and last points in the segment must be on curves. The returned list of points will not include the first on curve point. false curves (where the off curves are not any different from the on curves) must not be sent here. duplicate points ...
[ "Flatten", "the", "curve", "segment", "int", "a", "list", "of", "points", ".", "The", "first", "and", "last", "points", "in", "the", "segment", "must", "be", "on", "curves", ".", "The", "returned", "list", "of", "points", "will", "not", "include", "the",...
b7d9fc95c155824662f4a0020e653c77b7723d24
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L1059-L1086
train
typemytype/booleanOperations
Lib/booleanOperations/flatten.py
_estimateCubicCurveLength
def _estimateCubicCurveLength(pt0, pt1, pt2, pt3, precision=10): """ Estimate the length of this curve by iterating through it and averaging the length of the flat bits. """ points = [] length = 0 step = 1.0 / precision factors = range(0, precision + 1) for i in factors: poin...
python
def _estimateCubicCurveLength(pt0, pt1, pt2, pt3, precision=10): """ Estimate the length of this curve by iterating through it and averaging the length of the flat bits. """ points = [] length = 0 step = 1.0 / precision factors = range(0, precision + 1) for i in factors: poin...
[ "def", "_estimateCubicCurveLength", "(", "pt0", ",", "pt1", ",", "pt2", ",", "pt3", ",", "precision", "=", "10", ")", ":", "points", "=", "[", "]", "length", "=", "0", "step", "=", "1.0", "/", "precision", "factors", "=", "range", "(", "0", ",", "p...
Estimate the length of this curve by iterating through it and averaging the length of the flat bits.
[ "Estimate", "the", "length", "of", "this", "curve", "by", "iterating", "through", "it", "and", "averaging", "the", "length", "of", "the", "flat", "bits", "." ]
b7d9fc95c155824662f4a0020e653c77b7723d24
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L1097-L1112
train
typemytype/booleanOperations
Lib/booleanOperations/flatten.py
_mid
def _mid(pt1, pt2): """ (Point, Point) -> Point Return the point that lies in between the two input points. """ (x0, y0), (x1, y1) = pt1, pt2 return 0.5 * (x0 + x1), 0.5 * (y0 + y1)
python
def _mid(pt1, pt2): """ (Point, Point) -> Point Return the point that lies in between the two input points. """ (x0, y0), (x1, y1) = pt1, pt2 return 0.5 * (x0 + x1), 0.5 * (y0 + y1)
[ "def", "_mid", "(", "pt1", ",", "pt2", ")", ":", "(", "x0", ",", "y0", ")", ",", "(", "x1", ",", "y1", ")", "=", "pt1", ",", "pt2", "return", "0.5", "*", "(", "x0", "+", "x1", ")", ",", "0.5", "*", "(", "y0", "+", "y1", ")" ]
(Point, Point) -> Point Return the point that lies in between the two input points.
[ "(", "Point", "Point", ")", "-", ">", "Point", "Return", "the", "point", "that", "lies", "in", "between", "the", "two", "input", "points", "." ]
b7d9fc95c155824662f4a0020e653c77b7723d24
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L1115-L1121
train
typemytype/booleanOperations
Lib/booleanOperations/flatten.py
InputSegment.split
def split(self, tValues): """ Split the segment according the t values """ if self.segmentType == "curve": on1 = self.previousOnCurve off1 = self.points[0].coordinates off2 = self.points[1].coordinates on2 = self.points[2].coordinates ...
python
def split(self, tValues): """ Split the segment according the t values """ if self.segmentType == "curve": on1 = self.previousOnCurve off1 = self.points[0].coordinates off2 = self.points[1].coordinates on2 = self.points[2].coordinates ...
[ "def", "split", "(", "self", ",", "tValues", ")", ":", "if", "self", ".", "segmentType", "==", "\"curve\"", ":", "on1", "=", "self", ".", "previousOnCurve", "off1", "=", "self", ".", "points", "[", "0", "]", ".", "coordinates", "off2", "=", "self", "...
Split the segment according the t values
[ "Split", "the", "segment", "according", "the", "t", "values" ]
b7d9fc95c155824662f4a0020e653c77b7723d24
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L211-L237
train
typemytype/booleanOperations
Lib/booleanOperations/flatten.py
InputSegment.tValueForPoint
def tValueForPoint(self, point): """ get a t values for a given point required: the point must be a point on the curve. in an overlap cause the point will be an intersection points wich is alwasy a point on the curve """ if self.segmentType == "curve": ...
python
def tValueForPoint(self, point): """ get a t values for a given point required: the point must be a point on the curve. in an overlap cause the point will be an intersection points wich is alwasy a point on the curve """ if self.segmentType == "curve": ...
[ "def", "tValueForPoint", "(", "self", ",", "point", ")", ":", "if", "self", ".", "segmentType", "==", "\"curve\"", ":", "on1", "=", "self", ".", "previousOnCurve", "off1", "=", "self", ".", "points", "[", "0", "]", ".", "coordinates", "off2", "=", "sel...
get a t values for a given point required: the point must be a point on the curve. in an overlap cause the point will be an intersection points wich is alwasy a point on the curve
[ "get", "a", "t", "values", "for", "a", "given", "point", "required", ":", "the", "point", "must", "be", "a", "point", "on", "the", "curve", ".", "in", "an", "overlap", "cause", "the", "point", "will", "be", "an", "intersection", "points", "wich", "is",...
b7d9fc95c155824662f4a0020e653c77b7723d24
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L239-L257
train
typemytype/booleanOperations
Lib/booleanOperations/flatten.py
ContourPointDataPen.getData
def getData(self): """ Return a list of normalized InputPoint objects for the contour drawn with this pen. """ # organize the points into segments # 1. make sure there is an on curve haveOnCurve = False for point in self._points: if point.segme...
python
def getData(self): """ Return a list of normalized InputPoint objects for the contour drawn with this pen. """ # organize the points into segments # 1. make sure there is an on curve haveOnCurve = False for point in self._points: if point.segme...
[ "def", "getData", "(", "self", ")", ":", "# organize the points into segments", "# 1. make sure there is an on curve", "haveOnCurve", "=", "False", "for", "point", "in", "self", ".", "_points", ":", "if", "point", ".", "segmentType", "is", "not", "None", ":", "hav...
Return a list of normalized InputPoint objects for the contour drawn with this pen.
[ "Return", "a", "list", "of", "normalized", "InputPoint", "objects", "for", "the", "contour", "drawn", "with", "this", "pen", "." ]
b7d9fc95c155824662f4a0020e653c77b7723d24
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L307-L332
train
typemytype/booleanOperations
Lib/booleanOperations/flatten.py
OutputContour.reCurveFromEntireInputContour
def reCurveFromEntireInputContour(self, inputContour): """ Match if entire input contour matches entire output contour, allowing for different start point. """ if self.clockwise: inputFlat = inputContour.clockwiseFlat else: inputFlat = inputContour...
python
def reCurveFromEntireInputContour(self, inputContour): """ Match if entire input contour matches entire output contour, allowing for different start point. """ if self.clockwise: inputFlat = inputContour.clockwiseFlat else: inputFlat = inputContour...
[ "def", "reCurveFromEntireInputContour", "(", "self", ",", "inputContour", ")", ":", "if", "self", ".", "clockwise", ":", "inputFlat", "=", "inputContour", ".", "clockwiseFlat", "else", ":", "inputFlat", "=", "inputContour", ".", "counterClockwiseFlat", "outputFlat",...
Match if entire input contour matches entire output contour, allowing for different start point.
[ "Match", "if", "entire", "input", "contour", "matches", "entire", "output", "contour", "allowing", "for", "different", "start", "point", "." ]
b7d9fc95c155824662f4a0020e653c77b7723d24
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L496-L559
train
jucacrispim/pylint-mongoengine
pylint_mongoengine/suppression.py
_is_custom_qs_manager
def _is_custom_qs_manager(funcdef): """Checks if a function definition is a queryset manager created with the @queryset_manager decorator.""" decors = getattr(funcdef, 'decorators', None) if decors: for dec in decors.get_children(): try: if dec.name == 'queryset_mana...
python
def _is_custom_qs_manager(funcdef): """Checks if a function definition is a queryset manager created with the @queryset_manager decorator.""" decors = getattr(funcdef, 'decorators', None) if decors: for dec in decors.get_children(): try: if dec.name == 'queryset_mana...
[ "def", "_is_custom_qs_manager", "(", "funcdef", ")", ":", "decors", "=", "getattr", "(", "funcdef", ",", "'decorators'", ",", "None", ")", "if", "decors", ":", "for", "dec", "in", "decors", ".", "get_children", "(", ")", ":", "try", ":", "if", "dec", "...
Checks if a function definition is a queryset manager created with the @queryset_manager decorator.
[ "Checks", "if", "a", "function", "definition", "is", "a", "queryset", "manager", "created", "with", "the" ]
b873653d1224a5748f75dd507f492f8c60d95ce3
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/suppression.py#L27-L40
train
jucacrispim/pylint-mongoengine
pylint_mongoengine/suppression.py
_is_call2custom_manager
def _is_call2custom_manager(node): """Checks if the call is being done to a custom queryset manager.""" called = safe_infer(node.func) funcdef = getattr(called, '_proxied', None) return _is_custom_qs_manager(funcdef)
python
def _is_call2custom_manager(node): """Checks if the call is being done to a custom queryset manager.""" called = safe_infer(node.func) funcdef = getattr(called, '_proxied', None) return _is_custom_qs_manager(funcdef)
[ "def", "_is_call2custom_manager", "(", "node", ")", ":", "called", "=", "safe_infer", "(", "node", ".", "func", ")", "funcdef", "=", "getattr", "(", "called", ",", "'_proxied'", ",", "None", ")", "return", "_is_custom_qs_manager", "(", "funcdef", ")" ]
Checks if the call is being done to a custom queryset manager.
[ "Checks", "if", "the", "call", "is", "being", "done", "to", "a", "custom", "queryset", "manager", "." ]
b873653d1224a5748f75dd507f492f8c60d95ce3
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/suppression.py#L43-L47
train
jucacrispim/pylint-mongoengine
pylint_mongoengine/suppression.py
_is_custom_manager_attribute
def _is_custom_manager_attribute(node): """Checks if the attribute is a valid attribute for a queryset manager. """ attrname = node.attrname if not name_is_from_qs(attrname): return False for attr in node.get_children(): inferred = safe_infer(attr) funcdef = getattr(inferre...
python
def _is_custom_manager_attribute(node): """Checks if the attribute is a valid attribute for a queryset manager. """ attrname = node.attrname if not name_is_from_qs(attrname): return False for attr in node.get_children(): inferred = safe_infer(attr) funcdef = getattr(inferre...
[ "def", "_is_custom_manager_attribute", "(", "node", ")", ":", "attrname", "=", "node", ".", "attrname", "if", "not", "name_is_from_qs", "(", "attrname", ")", ":", "return", "False", "for", "attr", "in", "node", ".", "get_children", "(", ")", ":", "inferred",...
Checks if the attribute is a valid attribute for a queryset manager.
[ "Checks", "if", "the", "attribute", "is", "a", "valid", "attribute", "for", "a", "queryset", "manager", "." ]
b873653d1224a5748f75dd507f492f8c60d95ce3
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/suppression.py#L50-L64
train
ergo/ziggurat_foundations
ziggurat_foundations/models/services/group_permission.py
GroupPermissionService.by_group_and_perm
def by_group_and_perm(cls, group_id, perm_name, db_session=None): """ return by by_user_and_perm and permission name :param group_id: :param perm_name: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.quer...
python
def by_group_and_perm(cls, group_id, perm_name, db_session=None): """ return by by_user_and_perm and permission name :param group_id: :param perm_name: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.quer...
[ "def", "by_group_and_perm", "(", "cls", ",", "group_id", ",", "perm_name", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "model", ")", ".", ...
return by by_user_and_perm and permission name :param group_id: :param perm_name: :param db_session: :return:
[ "return", "by", "by_user_and_perm", "and", "permission", "name" ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/group_permission.py#L26-L38
train
stephenmcd/gnotty
gnotty/server.py
serve_forever
def serve_forever(django=False): """ Starts the gevent-socketio server. """ logger = getLogger("irc.dispatch") logger.setLevel(settings.LOG_LEVEL) logger.addHandler(StreamHandler()) app = IRCApplication(django) server = SocketIOServer((settings.HTTP_HOST, settings.HTTP_PORT), app) pr...
python
def serve_forever(django=False): """ Starts the gevent-socketio server. """ logger = getLogger("irc.dispatch") logger.setLevel(settings.LOG_LEVEL) logger.addHandler(StreamHandler()) app = IRCApplication(django) server = SocketIOServer((settings.HTTP_HOST, settings.HTTP_PORT), app) pr...
[ "def", "serve_forever", "(", "django", "=", "False", ")", ":", "logger", "=", "getLogger", "(", "\"irc.dispatch\"", ")", "logger", ".", "setLevel", "(", "settings", ".", "LOG_LEVEL", ")", "logger", ".", "addHandler", "(", "StreamHandler", "(", ")", ")", "a...
Starts the gevent-socketio server.
[ "Starts", "the", "gevent", "-", "socketio", "server", "." ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L243-L258
train
stephenmcd/gnotty
gnotty/server.py
kill
def kill(pid_file): """ Attempts to shut down a previously started daemon. """ try: with open(pid_file) as f: os.kill(int(f.read()), 9) os.remove(pid_file) except (IOError, OSError): return False return True
python
def kill(pid_file): """ Attempts to shut down a previously started daemon. """ try: with open(pid_file) as f: os.kill(int(f.read()), 9) os.remove(pid_file) except (IOError, OSError): return False return True
[ "def", "kill", "(", "pid_file", ")", ":", "try", ":", "with", "open", "(", "pid_file", ")", "as", "f", ":", "os", ".", "kill", "(", "int", "(", "f", ".", "read", "(", ")", ")", ",", "9", ")", "os", ".", "remove", "(", "pid_file", ")", "except...
Attempts to shut down a previously started daemon.
[ "Attempts", "to", "shut", "down", "a", "previously", "started", "daemon", "." ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L261-L271
train
stephenmcd/gnotty
gnotty/server.py
run
def run(): """ CLI entry point. Parses args and starts the gevent-socketio server. """ settings.parse_args() pid_name = "gnotty-%s-%s.pid" % (settings.HTTP_HOST, settings.HTTP_PORT) pid_file = settings.PID_FILE or os.path.join(gettempdir(), pid_name) if settings.KILL: if kill(pid_fil...
python
def run(): """ CLI entry point. Parses args and starts the gevent-socketio server. """ settings.parse_args() pid_name = "gnotty-%s-%s.pid" % (settings.HTTP_HOST, settings.HTTP_PORT) pid_file = settings.PID_FILE or os.path.join(gettempdir(), pid_name) if settings.KILL: if kill(pid_fil...
[ "def", "run", "(", ")", ":", "settings", ".", "parse_args", "(", ")", "pid_name", "=", "\"gnotty-%s-%s.pid\"", "%", "(", "settings", ".", "HTTP_HOST", ",", "settings", ".", "HTTP_PORT", ")", "pid_file", "=", "settings", ".", "PID_FILE", "or", "os", ".", ...
CLI entry point. Parses args and starts the gevent-socketio server.
[ "CLI", "entry", "point", ".", "Parses", "args", "and", "starts", "the", "gevent", "-", "socketio", "server", "." ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L274-L291
train
stephenmcd/gnotty
gnotty/server.py
IRCNamespace.on_start
def on_start(self, host, port, channel, nickname, password): """ A WebSocket session has started - create a greenlet to host the IRC client, and start it. """ self.client = WebSocketIRCClient(host, port, channel, nickname, password, self) ...
python
def on_start(self, host, port, channel, nickname, password): """ A WebSocket session has started - create a greenlet to host the IRC client, and start it. """ self.client = WebSocketIRCClient(host, port, channel, nickname, password, self) ...
[ "def", "on_start", "(", "self", ",", "host", ",", "port", ",", "channel", ",", "nickname", ",", "password", ")", ":", "self", ".", "client", "=", "WebSocketIRCClient", "(", "host", ",", "port", ",", "channel", ",", "nickname", ",", "password", ",", "se...
A WebSocket session has started - create a greenlet to host the IRC client, and start it.
[ "A", "WebSocket", "session", "has", "started", "-", "create", "a", "greenlet", "to", "host", "the", "IRC", "client", "and", "start", "it", "." ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L39-L46
train
stephenmcd/gnotty
gnotty/server.py
IRCNamespace.disconnect
def disconnect(self, *args, **kwargs): """ WebSocket was disconnected - leave the IRC channel. """ quit_message = "%s %s" % (settings.GNOTTY_VERSION_STRING, settings.GNOTTY_PROJECT_URL) self.client.connection.quit(quit_message) super(IRCN...
python
def disconnect(self, *args, **kwargs): """ WebSocket was disconnected - leave the IRC channel. """ quit_message = "%s %s" % (settings.GNOTTY_VERSION_STRING, settings.GNOTTY_PROJECT_URL) self.client.connection.quit(quit_message) super(IRCN...
[ "def", "disconnect", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "quit_message", "=", "\"%s %s\"", "%", "(", "settings", ".", "GNOTTY_VERSION_STRING", ",", "settings", ".", "GNOTTY_PROJECT_URL", ")", "self", ".", "client", ".", "conne...
WebSocket was disconnected - leave the IRC channel.
[ "WebSocket", "was", "disconnected", "-", "leave", "the", "IRC", "channel", "." ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L55-L62
train
stephenmcd/gnotty
gnotty/server.py
IRCApplication.bot_watcher
def bot_watcher(self): """ Thread (greenlet) that will try and reconnect the bot if it's not connected. """ default_interval = 5 interval = default_interval while True: if not self.bot.connection.connected: if self.bot.reconnect(): ...
python
def bot_watcher(self): """ Thread (greenlet) that will try and reconnect the bot if it's not connected. """ default_interval = 5 interval = default_interval while True: if not self.bot.connection.connected: if self.bot.reconnect(): ...
[ "def", "bot_watcher", "(", "self", ")", ":", "default_interval", "=", "5", "interval", "=", "default_interval", "while", "True", ":", "if", "not", "self", ".", "bot", ".", "connection", ".", "connected", ":", "if", "self", ".", "bot", ".", "reconnect", "...
Thread (greenlet) that will try and reconnect the bot if it's not connected.
[ "Thread", "(", "greenlet", ")", "that", "will", "try", "and", "reconnect", "the", "bot", "if", "it", "s", "not", "connected", "." ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L86-L99
train
stephenmcd/gnotty
gnotty/server.py
IRCApplication.respond_webhook
def respond_webhook(self, environ): """ Passes the request onto a bot with a webhook if the webhook path is requested. """ request = FieldStorage(fp=environ["wsgi.input"], environ=environ) url = environ["PATH_INFO"] params = dict([(k, request[k].value) for k in re...
python
def respond_webhook(self, environ): """ Passes the request onto a bot with a webhook if the webhook path is requested. """ request = FieldStorage(fp=environ["wsgi.input"], environ=environ) url = environ["PATH_INFO"] params = dict([(k, request[k].value) for k in re...
[ "def", "respond_webhook", "(", "self", ",", "environ", ")", ":", "request", "=", "FieldStorage", "(", "fp", "=", "environ", "[", "\"wsgi.input\"", "]", ",", "environ", "=", "environ", ")", "url", "=", "environ", "[", "\"PATH_INFO\"", "]", "params", "=", ...
Passes the request onto a bot with a webhook if the webhook path is requested.
[ "Passes", "the", "request", "onto", "a", "bot", "with", "a", "webhook", "if", "the", "webhook", "path", "is", "requested", "." ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L101-L118
train
stephenmcd/gnotty
gnotty/server.py
IRCApplication.respond_static
def respond_static(self, environ): """ Serves a static file when Django isn't being used. """ path = os.path.normpath(environ["PATH_INFO"]) if path == "/": content = self.index() content_type = "text/html" else: path = os.path.join(os.p...
python
def respond_static(self, environ): """ Serves a static file when Django isn't being used. """ path = os.path.normpath(environ["PATH_INFO"]) if path == "/": content = self.index() content_type = "text/html" else: path = os.path.join(os.p...
[ "def", "respond_static", "(", "self", ",", "environ", ")", ":", "path", "=", "os", ".", "path", ".", "normpath", "(", "environ", "[", "\"PATH_INFO\"", "]", ")", "if", "path", "==", "\"/\"", ":", "content", "=", "self", ".", "index", "(", ")", "conten...
Serves a static file when Django isn't being used.
[ "Serves", "a", "static", "file", "when", "Django", "isn", "t", "being", "used", "." ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L120-L136
train
stephenmcd/gnotty
gnotty/server.py
IRCApplication.index
def index(self): """ Loads the chat interface template when Django isn't being used, manually dealing with the Django template bits. """ root_dir = os.path.dirname(__file__) template_dir = os.path.join(root_dir, "templates", "gnotty") with open(os.path.join(templa...
python
def index(self): """ Loads the chat interface template when Django isn't being used, manually dealing with the Django template bits. """ root_dir = os.path.dirname(__file__) template_dir = os.path.join(root_dir, "templates", "gnotty") with open(os.path.join(templa...
[ "def", "index", "(", "self", ")", ":", "root_dir", "=", "os", ".", "path", ".", "dirname", "(", "__file__", ")", "template_dir", "=", "os", ".", "path", ".", "join", "(", "root_dir", ",", "\"templates\"", ",", "\"gnotty\"", ")", "with", "open", "(", ...
Loads the chat interface template when Django isn't being used, manually dealing with the Django template bits.
[ "Loads", "the", "chat", "interface", "template", "when", "Django", "isn", "t", "being", "used", "manually", "dealing", "with", "the", "Django", "template", "bits", "." ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L138-L164
train
stephenmcd/gnotty
gnotty/server.py
IRCApplication.authorized
def authorized(self, environ): """ If we're running Django and ``GNOTTY_LOGIN_REQUIRED`` is set to ``True``, pull the session cookie from the environment and validate that the user is authenticated. """ if self.django and settings.LOGIN_REQUIRED: try: ...
python
def authorized(self, environ): """ If we're running Django and ``GNOTTY_LOGIN_REQUIRED`` is set to ``True``, pull the session cookie from the environment and validate that the user is authenticated. """ if self.django and settings.LOGIN_REQUIRED: try: ...
[ "def", "authorized", "(", "self", ",", "environ", ")", ":", "if", "self", ".", "django", "and", "settings", ".", "LOGIN_REQUIRED", ":", "try", ":", "from", "django", ".", "conf", "import", "settings", "as", "django_settings", "from", "django", ".", "contri...
If we're running Django and ``GNOTTY_LOGIN_REQUIRED`` is set to ``True``, pull the session cookie from the environment and validate that the user is authenticated.
[ "If", "we", "re", "running", "Django", "and", "GNOTTY_LOGIN_REQUIRED", "is", "set", "to", "True", "pull", "the", "session", "cookie", "from", "the", "environment", "and", "validate", "that", "the", "user", "is", "authenticated", "." ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L186-L207
train
stephenmcd/gnotty
gnotty/migrations/0003_joins_leaves.py
Migration.forwards
def forwards(self, orm): "Write your forwards methods here." # Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..." if not db.dry_run: orm['gnotty.IRCMessage'].objects.filter(message="joins").update(join_or_leave=True) orm['gnotty.IRCMessage...
python
def forwards(self, orm): "Write your forwards methods here." # Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..." if not db.dry_run: orm['gnotty.IRCMessage'].objects.filter(message="joins").update(join_or_leave=True) orm['gnotty.IRCMessage...
[ "def", "forwards", "(", "self", ",", "orm", ")", ":", "# Note: Remember to use orm['appname.ModelName'] rather than \"from appname.models...\"", "if", "not", "db", ".", "dry_run", ":", "orm", "[", "'gnotty.IRCMessage'", "]", ".", "objects", ".", "filter", "(", "messag...
Write your forwards methods here.
[ "Write", "your", "forwards", "methods", "here", "." ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/migrations/0003_joins_leaves.py#L9-L14
train
ergo/ziggurat_foundations
ziggurat_foundations/permissions.py
resource_permissions_for_users
def resource_permissions_for_users( models_proxy, perm_names, resource_ids=None, user_ids=None, group_ids=None, resource_types=None, limit_group_permissions=False, skip_user_perms=False, skip_group_perms=False, db_session=None, ): """ Returns permission tuples that match ...
python
def resource_permissions_for_users( models_proxy, perm_names, resource_ids=None, user_ids=None, group_ids=None, resource_types=None, limit_group_permissions=False, skip_user_perms=False, skip_group_perms=False, db_session=None, ): """ Returns permission tuples that match ...
[ "def", "resource_permissions_for_users", "(", "models_proxy", ",", "perm_names", ",", "resource_ids", "=", "None", ",", "user_ids", "=", "None", ",", "group_ids", "=", "None", ",", "resource_types", "=", "None", ",", "limit_group_permissions", "=", "False", ",", ...
Returns permission tuples that match one of passed permission names perm_names - list of permissions that can be matched user_ids - restrict to specific users group_ids - restrict to specific groups resource_ids - restrict to specific resources limit_group_permissions - should be used if we do not w...
[ "Returns", "permission", "tuples", "that", "match", "one", "of", "passed", "permission", "names", "perm_names", "-", "list", "of", "permissions", "that", "can", "be", "matched", "user_ids", "-", "restrict", "to", "specific", "users", "group_ids", "-", "restrict"...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/permissions.py#L59-L186
train