id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
41,500 | erikvw/django-collect-offline-files | django_collect_offline_files/file_queues/deserialize_transactions_file_queue.py | DeserializeTransactionsFileQueue.get_batch | def get_batch(self, filename=None):
"""Returns a batch instance given the filename.
"""
try:
history = self.history_model.objects.get(filename=filename)
except self.history_model.DoesNotExist as e:
raise TransactionsFileQueueError(
f"Batch history ... | python | def get_batch(self, filename=None):
"""Returns a batch instance given the filename.
"""
try:
history = self.history_model.objects.get(filename=filename)
except self.history_model.DoesNotExist as e:
raise TransactionsFileQueueError(
f"Batch history ... | [
"def",
"get_batch",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"try",
":",
"history",
"=",
"self",
".",
"history_model",
".",
"objects",
".",
"get",
"(",
"filename",
"=",
"filename",
")",
"except",
"self",
".",
"history_model",
".",
"DoesNotExi... | Returns a batch instance given the filename. | [
"Returns",
"a",
"batch",
"instance",
"given",
"the",
"filename",
"."
] | 78f61c823ea3926eb88206b019b5dca3c36017da | https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/file_queues/deserialize_transactions_file_queue.py#L44-L60 |
41,501 | MacHu-GWU/crawl_zillow-project | crawl_zillow/htmlparser.py | HTMLParser.get_items | def get_items(self, html):
"""
Get state, county, zipcode, address code from lists page.
Example:
target url: http://www.zillow.com/browse/homes/md/
<<<<<<< HEAD
data: ``[(href, name), ...]``
=======
data: [(href, name)]
>>>>>>> 4507a26c6cc47e0affe1f7000f912e... | python | def get_items(self, html):
"""
Get state, county, zipcode, address code from lists page.
Example:
target url: http://www.zillow.com/browse/homes/md/
<<<<<<< HEAD
data: ``[(href, name), ...]``
=======
data: [(href, name)]
>>>>>>> 4507a26c6cc47e0affe1f7000f912e... | [
"def",
"get_items",
"(",
"self",
",",
"html",
")",
":",
"captcha_patterns",
"=",
"[",
"\"https://www.google.com/recaptcha/api.js\"",
",",
"\"I'm not a robot\"",
"]",
"for",
"captcha_pattern",
"in",
"captcha_patterns",
":",
"if",
"captcha_pattern",
"in",
"html",
":",
... | Get state, county, zipcode, address code from lists page.
Example:
target url: http://www.zillow.com/browse/homes/md/
<<<<<<< HEAD
data: ``[(href, name), ...]``
=======
data: [(href, name)]
>>>>>>> 4507a26c6cc47e0affe1f7000f912e536c45212b | [
"Get",
"state",
"county",
"zipcode",
"address",
"code",
"from",
"lists",
"page",
"."
] | c6d7ca8e4c80e7e7e963496433ef73df1413c16e | https://github.com/MacHu-GWU/crawl_zillow-project/blob/c6d7ca8e4c80e7e7e963496433ef73df1413c16e/crawl_zillow/htmlparser.py#L11-L39 |
41,502 | asascience-open/paegan-transport | paegan/transport/models/behaviors/diel.py | Diel.get_time | def get_time(self, loc4d=None):
"""
Based on a Location4D object and this Diel object, calculate
the time at which this Diel migration is actually happening
"""
if loc4d is None:
raise ValueError("Location4D object can not be None")
if self.pattern ==... | python | def get_time(self, loc4d=None):
"""
Based on a Location4D object and this Diel object, calculate
the time at which this Diel migration is actually happening
"""
if loc4d is None:
raise ValueError("Location4D object can not be None")
if self.pattern ==... | [
"def",
"get_time",
"(",
"self",
",",
"loc4d",
"=",
"None",
")",
":",
"if",
"loc4d",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Location4D object can not be None\"",
")",
"if",
"self",
".",
"pattern",
"==",
"self",
".",
"PATTERN_CYCLE",
":",
"c",
"="... | Based on a Location4D object and this Diel object, calculate
the time at which this Diel migration is actually happening | [
"Based",
"on",
"a",
"Location4D",
"object",
"and",
"this",
"Diel",
"object",
"calculate",
"the",
"time",
"at",
"which",
"this",
"Diel",
"migration",
"is",
"actually",
"happening"
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/models/behaviors/diel.py#L95-L116 |
41,503 | asascience-open/paegan-transport | paegan/transport/models/behaviors/diel.py | Diel.move | def move(self, particle, u, v, w, modelTimestep, **kwargs):
# If the particle is settled, don't move it anywhere
if particle.settled:
return { 'u': 0, 'v': 0, 'w': 0 }
# If the particle is halted (but not settled), don't move it anywhere
if particle.halted:
retu... | python | def move(self, particle, u, v, w, modelTimestep, **kwargs):
# If the particle is settled, don't move it anywhere
if particle.settled:
return { 'u': 0, 'v': 0, 'w': 0 }
# If the particle is halted (but not settled), don't move it anywhere
if particle.halted:
retu... | [
"def",
"move",
"(",
"self",
",",
"particle",
",",
"u",
",",
"v",
",",
"w",
",",
"modelTimestep",
",",
"*",
"*",
"kwargs",
")",
":",
"# If the particle is settled, don't move it anywhere",
"if",
"particle",
".",
"settled",
":",
"return",
"{",
"'u'",
":",
"0... | This only works if min is less than max.
No checks are done here, so it should be done before
calling this function. | [
"This",
"only",
"works",
"if",
"min",
"is",
"less",
"than",
"max",
".",
"No",
"checks",
"are",
"done",
"here",
"so",
"it",
"should",
"be",
"done",
"before",
"calling",
"this",
"function",
"."
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/models/behaviors/diel.py#L119-L186 |
41,504 | helixyte/everest | everest/entities/base.py | RootAggregate.make_relationship_aggregate | def make_relationship_aggregate(self, relationship):
"""
Returns a new relationship aggregate for the given relationship.
:param relationship: Instance of
:class:`everest.entities.relationship.DomainRelationship`.
"""
if not self._session.IS_MANAGING_BACKREFERENCES:
... | python | def make_relationship_aggregate(self, relationship):
"""
Returns a new relationship aggregate for the given relationship.
:param relationship: Instance of
:class:`everest.entities.relationship.DomainRelationship`.
"""
if not self._session.IS_MANAGING_BACKREFERENCES:
... | [
"def",
"make_relationship_aggregate",
"(",
"self",
",",
"relationship",
")",
":",
"if",
"not",
"self",
".",
"_session",
".",
"IS_MANAGING_BACKREFERENCES",
":",
"relationship",
".",
"direction",
"&=",
"~",
"RELATIONSHIP_DIRECTIONS",
".",
"REVERSE",
"return",
"Relatio... | Returns a new relationship aggregate for the given relationship.
:param relationship: Instance of
:class:`everest.entities.relationship.DomainRelationship`. | [
"Returns",
"a",
"new",
"relationship",
"aggregate",
"for",
"the",
"given",
"relationship",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/entities/base.py#L462-L471 |
41,505 | helixyte/everest | everest/repositories/uow.py | UnitOfWork.register_new | def register_new(self, entity_class, entity):
"""
Registers the given entity for the given class as NEW.
:raises ValueError: If the given entity already holds state that was
created by another Unit Of Work.
"""
EntityState.manage(entity, self)
EntityState.get_s... | python | def register_new(self, entity_class, entity):
"""
Registers the given entity for the given class as NEW.
:raises ValueError: If the given entity already holds state that was
created by another Unit Of Work.
"""
EntityState.manage(entity, self)
EntityState.get_s... | [
"def",
"register_new",
"(",
"self",
",",
"entity_class",
",",
"entity",
")",
":",
"EntityState",
".",
"manage",
"(",
"entity",
",",
"self",
")",
"EntityState",
".",
"get_state",
"(",
"entity",
")",
".",
"status",
"=",
"ENTITY_STATUS",
".",
"NEW",
"self",
... | Registers the given entity for the given class as NEW.
:raises ValueError: If the given entity already holds state that was
created by another Unit Of Work. | [
"Registers",
"the",
"given",
"entity",
"for",
"the",
"given",
"class",
"as",
"NEW",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/uow.py#L31-L40 |
41,506 | helixyte/everest | everest/repositories/uow.py | UnitOfWork.register_clean | def register_clean(self, entity_class, entity):
"""
Registers the given entity for the given class as CLEAN.
:returns: Cloned entity.
"""
EntityState.manage(entity, self)
EntityState.get_state(entity).status = ENTITY_STATUS.CLEAN
self.__entity_set_map[entity_clas... | python | def register_clean(self, entity_class, entity):
"""
Registers the given entity for the given class as CLEAN.
:returns: Cloned entity.
"""
EntityState.manage(entity, self)
EntityState.get_state(entity).status = ENTITY_STATUS.CLEAN
self.__entity_set_map[entity_clas... | [
"def",
"register_clean",
"(",
"self",
",",
"entity_class",
",",
"entity",
")",
":",
"EntityState",
".",
"manage",
"(",
"entity",
",",
"self",
")",
"EntityState",
".",
"get_state",
"(",
"entity",
")",
".",
"status",
"=",
"ENTITY_STATUS",
".",
"CLEAN",
"self... | Registers the given entity for the given class as CLEAN.
:returns: Cloned entity. | [
"Registers",
"the",
"given",
"entity",
"for",
"the",
"given",
"class",
"as",
"CLEAN",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/uow.py#L42-L50 |
41,507 | helixyte/everest | everest/repositories/uow.py | UnitOfWork.register_deleted | def register_deleted(self, entity_class, entity):
"""
Registers the given entity for the given class as DELETED.
:raises ValueError: If the given entity already holds state that was
created by another Unit Of Work.
"""
EntityState.manage(entity, self)
EntitySta... | python | def register_deleted(self, entity_class, entity):
"""
Registers the given entity for the given class as DELETED.
:raises ValueError: If the given entity already holds state that was
created by another Unit Of Work.
"""
EntityState.manage(entity, self)
EntitySta... | [
"def",
"register_deleted",
"(",
"self",
",",
"entity_class",
",",
"entity",
")",
":",
"EntityState",
".",
"manage",
"(",
"entity",
",",
"self",
")",
"EntityState",
".",
"get_state",
"(",
"entity",
")",
".",
"status",
"=",
"ENTITY_STATUS",
".",
"DELETED",
"... | Registers the given entity for the given class as DELETED.
:raises ValueError: If the given entity already holds state that was
created by another Unit Of Work. | [
"Registers",
"the",
"given",
"entity",
"for",
"the",
"given",
"class",
"as",
"DELETED",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/uow.py#L52-L61 |
41,508 | helixyte/everest | everest/repositories/uow.py | UnitOfWork.unregister | def unregister(self, entity_class, entity):
"""
Unregisters the given entity for the given class and discards its
state information.
"""
EntityState.release(entity, self)
self.__entity_set_map[entity_class].remove(entity) | python | def unregister(self, entity_class, entity):
"""
Unregisters the given entity for the given class and discards its
state information.
"""
EntityState.release(entity, self)
self.__entity_set_map[entity_class].remove(entity) | [
"def",
"unregister",
"(",
"self",
",",
"entity_class",
",",
"entity",
")",
":",
"EntityState",
".",
"release",
"(",
"entity",
",",
"self",
")",
"self",
".",
"__entity_set_map",
"[",
"entity_class",
"]",
".",
"remove",
"(",
"entity",
")"
] | Unregisters the given entity for the given class and discards its
state information. | [
"Unregisters",
"the",
"given",
"entity",
"for",
"the",
"given",
"class",
"and",
"discards",
"its",
"state",
"information",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/uow.py#L63-L69 |
41,509 | helixyte/everest | everest/repositories/uow.py | UnitOfWork.is_marked_new | def is_marked_new(self, entity):
"""
Checks if the given entity is marked with status NEW. Returns `False`
if the entity has no state information.
"""
try:
result = EntityState.get_state(entity).status == ENTITY_STATUS.NEW
except ValueError:
result... | python | def is_marked_new(self, entity):
"""
Checks if the given entity is marked with status NEW. Returns `False`
if the entity has no state information.
"""
try:
result = EntityState.get_state(entity).status == ENTITY_STATUS.NEW
except ValueError:
result... | [
"def",
"is_marked_new",
"(",
"self",
",",
"entity",
")",
":",
"try",
":",
"result",
"=",
"EntityState",
".",
"get_state",
"(",
"entity",
")",
".",
"status",
"==",
"ENTITY_STATUS",
".",
"NEW",
"except",
"ValueError",
":",
"result",
"=",
"False",
"return",
... | Checks if the given entity is marked with status NEW. Returns `False`
if the entity has no state information. | [
"Checks",
"if",
"the",
"given",
"entity",
"is",
"marked",
"with",
"status",
"NEW",
".",
"Returns",
"False",
"if",
"the",
"entity",
"has",
"no",
"state",
"information",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/uow.py#L78-L87 |
41,510 | helixyte/everest | everest/repositories/uow.py | UnitOfWork.is_marked_deleted | def is_marked_deleted(self, entity):
"""
Checks if the given entity is marked with status DELETED. Returns
`False` if the entity has no state information.
"""
try:
result = EntityState.get_state(entity).status \
== E... | python | def is_marked_deleted(self, entity):
"""
Checks if the given entity is marked with status DELETED. Returns
`False` if the entity has no state information.
"""
try:
result = EntityState.get_state(entity).status \
== E... | [
"def",
"is_marked_deleted",
"(",
"self",
",",
"entity",
")",
":",
"try",
":",
"result",
"=",
"EntityState",
".",
"get_state",
"(",
"entity",
")",
".",
"status",
"==",
"ENTITY_STATUS",
".",
"DELETED",
"except",
"ValueError",
":",
"result",
"=",
"False",
"re... | Checks if the given entity is marked with status DELETED. Returns
`False` if the entity has no state information. | [
"Checks",
"if",
"the",
"given",
"entity",
"is",
"marked",
"with",
"status",
"DELETED",
".",
"Returns",
"False",
"if",
"the",
"entity",
"has",
"no",
"state",
"information",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/uow.py#L89-L99 |
41,511 | helixyte/everest | everest/repositories/uow.py | UnitOfWork.mark_clean | def mark_clean(self, entity):
"""
Marks the given entity as CLEAN.
This is done when an entity is loaded fresh from the repository or
after a commit.
"""
state = EntityState.get_state(entity)
state.status = ENTITY_STATUS.CLEAN
state.is_persisted = True | python | def mark_clean(self, entity):
"""
Marks the given entity as CLEAN.
This is done when an entity is loaded fresh from the repository or
after a commit.
"""
state = EntityState.get_state(entity)
state.status = ENTITY_STATUS.CLEAN
state.is_persisted = True | [
"def",
"mark_clean",
"(",
"self",
",",
"entity",
")",
":",
"state",
"=",
"EntityState",
".",
"get_state",
"(",
"entity",
")",
"state",
".",
"status",
"=",
"ENTITY_STATUS",
".",
"CLEAN",
"state",
".",
"is_persisted",
"=",
"True"
] | Marks the given entity as CLEAN.
This is done when an entity is loaded fresh from the repository or
after a commit. | [
"Marks",
"the",
"given",
"entity",
"as",
"CLEAN",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/uow.py#L130-L139 |
41,512 | helixyte/everest | everest/repositories/uow.py | UnitOfWork.iterator | def iterator(self):
"""
Returns an iterator over all entity states held by this Unit Of Work.
"""
# FIXME: There is no dependency tracking; objects are iterated in
# random order.
for ent_cls in list(self.__entity_set_map.keys()):
for ent in self.__enti... | python | def iterator(self):
"""
Returns an iterator over all entity states held by this Unit Of Work.
"""
# FIXME: There is no dependency tracking; objects are iterated in
# random order.
for ent_cls in list(self.__entity_set_map.keys()):
for ent in self.__enti... | [
"def",
"iterator",
"(",
"self",
")",
":",
"# FIXME: There is no dependency tracking; objects are iterated in",
"# random order.",
"for",
"ent_cls",
"in",
"list",
"(",
"self",
".",
"__entity_set_map",
".",
"keys",
"(",
")",
")",
":",
"for",
"ent",
"in",
"self"... | Returns an iterator over all entity states held by this Unit Of Work. | [
"Returns",
"an",
"iterator",
"over",
"all",
"entity",
"states",
"held",
"by",
"this",
"Unit",
"Of",
"Work",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/uow.py#L203-L211 |
41,513 | AtomHash/evernode | evernode/classes/form_data.py | FormData.file_save | def file_save(self, name, filename=None, folder="", keep_ext=True) -> bool:
""" Easy save of a file """
if name in self.files:
file_object = self.files[name]
clean_filename = secure_filename(file_object.filename)
if filename is not None and keep_ext:
... | python | def file_save(self, name, filename=None, folder="", keep_ext=True) -> bool:
""" Easy save of a file """
if name in self.files:
file_object = self.files[name]
clean_filename = secure_filename(file_object.filename)
if filename is not None and keep_ext:
... | [
"def",
"file_save",
"(",
"self",
",",
"name",
",",
"filename",
"=",
"None",
",",
"folder",
"=",
"\"\"",
",",
"keep_ext",
"=",
"True",
")",
"->",
"bool",
":",
"if",
"name",
"in",
"self",
".",
"files",
":",
"file_object",
"=",
"self",
".",
"files",
"... | Easy save of a file | [
"Easy",
"save",
"of",
"a",
"file"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/form_data.py#L48-L61 |
41,514 | AtomHash/evernode | evernode/classes/form_data.py | FormData.parse | def parse(self, fail_callback=None):
""" Parse text fields and file fields for values and files """
# get text fields
for field in self.field_arguments:
self.values[field['name']] = self.__get_value(field['name'])
if self.values[field['name']] is None and field['requ... | python | def parse(self, fail_callback=None):
""" Parse text fields and file fields for values and files """
# get text fields
for field in self.field_arguments:
self.values[field['name']] = self.__get_value(field['name'])
if self.values[field['name']] is None and field['requ... | [
"def",
"parse",
"(",
"self",
",",
"fail_callback",
"=",
"None",
")",
":",
"# get text fields\r",
"for",
"field",
"in",
"self",
".",
"field_arguments",
":",
"self",
".",
"values",
"[",
"field",
"[",
"'name'",
"]",
"]",
"=",
"self",
".",
"__get_value",
"("... | Parse text fields and file fields for values and files | [
"Parse",
"text",
"fields",
"and",
"file",
"fields",
"for",
"values",
"and",
"files"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/form_data.py#L63-L78 |
41,515 | AtomHash/evernode | evernode/classes/form_data.py | FormData.__get_value | def __get_value(self, field_name):
""" Get request Json value by field name """
value = request.values.get(field_name)
if value is None:
if self.json_form_data is None:
value = None
elif field_name in self.json_form_data:
value = sel... | python | def __get_value(self, field_name):
""" Get request Json value by field name """
value = request.values.get(field_name)
if value is None:
if self.json_form_data is None:
value = None
elif field_name in self.json_form_data:
value = sel... | [
"def",
"__get_value",
"(",
"self",
",",
"field_name",
")",
":",
"value",
"=",
"request",
".",
"values",
".",
"get",
"(",
"field_name",
")",
"if",
"value",
"is",
"None",
":",
"if",
"self",
".",
"json_form_data",
"is",
"None",
":",
"value",
"=",
"None",
... | Get request Json value by field name | [
"Get",
"request",
"Json",
"value",
"by",
"field",
"name"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/form_data.py#L80-L88 |
41,516 | AtomHash/evernode | evernode/classes/form_data.py | FormData.__get_file | def __get_file(self, file):
""" Get request file and do a security check """
file_object = None
if file['name'] in request.files:
file_object = request.files[file['name']]
clean_filename = secure_filename(file_object.filename)
if clean_filename == '':
... | python | def __get_file(self, file):
""" Get request file and do a security check """
file_object = None
if file['name'] in request.files:
file_object = request.files[file['name']]
clean_filename = secure_filename(file_object.filename)
if clean_filename == '':
... | [
"def",
"__get_file",
"(",
"self",
",",
"file",
")",
":",
"file_object",
"=",
"None",
"if",
"file",
"[",
"'name'",
"]",
"in",
"request",
".",
"files",
":",
"file_object",
"=",
"request",
".",
"files",
"[",
"file",
"[",
"'name'",
"]",
"]",
"clean_filenam... | Get request file and do a security check | [
"Get",
"request",
"file",
"and",
"do",
"a",
"security",
"check"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/form_data.py#L90-L103 |
41,517 | AtomHash/evernode | evernode/classes/form_data.py | FormData.__allowed_extension | def __allowed_extension(self, filename, extensions):
""" Check allowed file extensions """
allowed_extensions = current_app.config['UPLOADS']['EXTENSIONS']
if extensions is not None:
allowed_extensions = extensions
return '.' in filename and filename.rsplit('.', 1)[1].lo... | python | def __allowed_extension(self, filename, extensions):
""" Check allowed file extensions """
allowed_extensions = current_app.config['UPLOADS']['EXTENSIONS']
if extensions is not None:
allowed_extensions = extensions
return '.' in filename and filename.rsplit('.', 1)[1].lo... | [
"def",
"__allowed_extension",
"(",
"self",
",",
"filename",
",",
"extensions",
")",
":",
"allowed_extensions",
"=",
"current_app",
".",
"config",
"[",
"'UPLOADS'",
"]",
"[",
"'EXTENSIONS'",
"]",
"if",
"extensions",
"is",
"not",
"None",
":",
"allowed_extensions",... | Check allowed file extensions | [
"Check",
"allowed",
"file",
"extensions"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/form_data.py#L105-L111 |
41,518 | AtomHash/evernode | evernode/classes/form_data.py | FormData.__invalid_request | def __invalid_request(self, error):
""" Error response on failure """
# TODO: make this modifiable
error = {
'error': {
'message': error
}
}
abort(JsonResponse(status_code=400, data=error)) | python | def __invalid_request(self, error):
""" Error response on failure """
# TODO: make this modifiable
error = {
'error': {
'message': error
}
}
abort(JsonResponse(status_code=400, data=error)) | [
"def",
"__invalid_request",
"(",
"self",
",",
"error",
")",
":",
"# TODO: make this modifiable\r",
"error",
"=",
"{",
"'error'",
":",
"{",
"'message'",
":",
"error",
"}",
"}",
"abort",
"(",
"JsonResponse",
"(",
"status_code",
"=",
"400",
",",
"data",
"=",
... | Error response on failure | [
"Error",
"response",
"on",
"failure"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/form_data.py#L113-L121 |
41,519 | dariusbakunas/rawdisk | rawdisk/util/rawstruct.py | RawStruct.get_field | def get_field(self, offset, length, format):
"""Returns unpacked Python struct array.
Args:
offset (int): offset to byte array within structure
length (int): how many bytes to unpack
format (str): Python struct format string for unpacking
See Also:
... | python | def get_field(self, offset, length, format):
"""Returns unpacked Python struct array.
Args:
offset (int): offset to byte array within structure
length (int): how many bytes to unpack
format (str): Python struct format string for unpacking
See Also:
... | [
"def",
"get_field",
"(",
"self",
",",
"offset",
",",
"length",
",",
"format",
")",
":",
"return",
"struct",
".",
"unpack",
"(",
"format",
",",
"self",
".",
"data",
"[",
"offset",
":",
"offset",
"+",
"length",
"]",
")",
"[",
"0",
"]"
] | Returns unpacked Python struct array.
Args:
offset (int): offset to byte array within structure
length (int): how many bytes to unpack
format (str): Python struct format string for unpacking
See Also:
https://docs.python.org/2/library/struct.html#format-... | [
"Returns",
"unpacked",
"Python",
"struct",
"array",
"."
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/util/rawstruct.py#L92-L103 |
41,520 | dariusbakunas/rawdisk | rawdisk/util/rawstruct.py | RawStruct.export | def export(self, filename, offset=0, length=None):
"""Exports byte array to specified destination
Args:
filename (str): destination to output file
offset (int): byte offset (default: 0)
"""
self.__validate_offset(filename=filename, offset=offset, length=length)
... | python | def export(self, filename, offset=0, length=None):
"""Exports byte array to specified destination
Args:
filename (str): destination to output file
offset (int): byte offset (default: 0)
"""
self.__validate_offset(filename=filename, offset=offset, length=length)
... | [
"def",
"export",
"(",
"self",
",",
"filename",
",",
"offset",
"=",
"0",
",",
"length",
"=",
"None",
")",
":",
"self",
".",
"__validate_offset",
"(",
"filename",
"=",
"filename",
",",
"offset",
"=",
"offset",
",",
"length",
"=",
"length",
")",
"with",
... | Exports byte array to specified destination
Args:
filename (str): destination to output file
offset (int): byte offset (default: 0) | [
"Exports",
"byte",
"array",
"to",
"specified",
"destination"
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/util/rawstruct.py#L206-L224 |
41,521 | yougov/vr.common | vr/common/utils.py | tmpdir | def tmpdir():
"""
Create a tempdir context for the cwd and remove it after.
"""
target = None
try:
with _tmpdir_extant() as target:
yield target
finally:
if target is not None:
shutil.rmtree(target, ignore_errors=True) | python | def tmpdir():
"""
Create a tempdir context for the cwd and remove it after.
"""
target = None
try:
with _tmpdir_extant() as target:
yield target
finally:
if target is not None:
shutil.rmtree(target, ignore_errors=True) | [
"def",
"tmpdir",
"(",
")",
":",
"target",
"=",
"None",
"try",
":",
"with",
"_tmpdir_extant",
"(",
")",
"as",
"target",
":",
"yield",
"target",
"finally",
":",
"if",
"target",
"is",
"not",
"None",
":",
"shutil",
".",
"rmtree",
"(",
"target",
",",
"ign... | Create a tempdir context for the cwd and remove it after. | [
"Create",
"a",
"tempdir",
"context",
"for",
"the",
"cwd",
"and",
"remove",
"it",
"after",
"."
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/utils.py#L31-L41 |
41,522 | yougov/vr.common | vr/common/utils.py | run | def run(command, verbose=False):
"""
Run a shell command. Capture the stdout and stderr as a single stream.
Capture the status code.
If verbose=True, then print command and the output to the terminal as it
comes in.
"""
def do_nothing(*args, **kwargs):
return None
v_print = p... | python | def run(command, verbose=False):
"""
Run a shell command. Capture the stdout and stderr as a single stream.
Capture the status code.
If verbose=True, then print command and the output to the terminal as it
comes in.
"""
def do_nothing(*args, **kwargs):
return None
v_print = p... | [
"def",
"run",
"(",
"command",
",",
"verbose",
"=",
"False",
")",
":",
"def",
"do_nothing",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"None",
"v_print",
"=",
"print",
"if",
"verbose",
"else",
"do_nothing",
"p",
"=",
"subprocess",
... | Run a shell command. Capture the stdout and stderr as a single stream.
Capture the status code.
If verbose=True, then print command and the output to the terminal as it
comes in. | [
"Run",
"a",
"shell",
"command",
".",
"Capture",
"the",
"stdout",
"and",
"stderr",
"as",
"a",
"single",
"stream",
".",
"Capture",
"the",
"status",
"code",
"."
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/utils.py#L101-L136 |
41,523 | yougov/vr.common | vr/common/utils.py | get_lxc_version | def get_lxc_version():
""" Asks the current host what version of LXC it has. Returns it as a
string. If LXC is not installed, raises subprocess.CalledProcessError"""
runner = functools.partial(
subprocess.check_output,
stderr=subprocess.STDOUT,
universal_newlines=True,
)
#... | python | def get_lxc_version():
""" Asks the current host what version of LXC it has. Returns it as a
string. If LXC is not installed, raises subprocess.CalledProcessError"""
runner = functools.partial(
subprocess.check_output,
stderr=subprocess.STDOUT,
universal_newlines=True,
)
#... | [
"def",
"get_lxc_version",
"(",
")",
":",
"runner",
"=",
"functools",
".",
"partial",
"(",
"subprocess",
".",
"check_output",
",",
"stderr",
"=",
"subprocess",
".",
"STDOUT",
",",
"universal_newlines",
"=",
"True",
",",
")",
"# Old LXC had an lxc-version executable... | Asks the current host what version of LXC it has. Returns it as a
string. If LXC is not installed, raises subprocess.CalledProcessError | [
"Asks",
"the",
"current",
"host",
"what",
"version",
"of",
"LXC",
"it",
"has",
".",
"Returns",
"it",
"as",
"a",
"string",
".",
"If",
"LXC",
"is",
"not",
"installed",
"raises",
"subprocess",
".",
"CalledProcessError"
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/utils.py#L238-L257 |
41,524 | RI-imaging/qpformat | qpformat/file_formats/single_hdf5_qpimage.py | SingleHdf5Qpimage.get_qpimage | def get_qpimage(self, idx=0):
"""Return background-corrected QPImage"""
if self._bgdata:
# The user has explicitly chosen different background data
# using `get_qpimage_raw`.
qpi = super(SingleHdf5Qpimage, self).get_qpimage()
else:
# We can use the... | python | def get_qpimage(self, idx=0):
"""Return background-corrected QPImage"""
if self._bgdata:
# The user has explicitly chosen different background data
# using `get_qpimage_raw`.
qpi = super(SingleHdf5Qpimage, self).get_qpimage()
else:
# We can use the... | [
"def",
"get_qpimage",
"(",
"self",
",",
"idx",
"=",
"0",
")",
":",
"if",
"self",
".",
"_bgdata",
":",
"# The user has explicitly chosen different background data",
"# using `get_qpimage_raw`.",
"qpi",
"=",
"super",
"(",
"SingleHdf5Qpimage",
",",
"self",
")",
".",
... | Return background-corrected QPImage | [
"Return",
"background",
"-",
"corrected",
"QPImage"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/single_hdf5_qpimage.py#L25-L42 |
41,525 | kmedian/ctmc | ctmc/simulate.py | simulate | def simulate(s0, transmat, steps=1):
"""Simulate the next state
Parameters
----------
s0 : ndarray
Vector with state variables at t=0
transmat : ndarray
The estimated transition/stochastic matrix.
steps : int
(Default: 1) The number of steps to simulate model outputs a... | python | def simulate(s0, transmat, steps=1):
"""Simulate the next state
Parameters
----------
s0 : ndarray
Vector with state variables at t=0
transmat : ndarray
The estimated transition/stochastic matrix.
steps : int
(Default: 1) The number of steps to simulate model outputs a... | [
"def",
"simulate",
"(",
"s0",
",",
"transmat",
",",
"steps",
"=",
"1",
")",
":",
"# Single-Step simulation",
"if",
"steps",
"==",
"1",
":",
"return",
"np",
".",
"dot",
"(",
"s0",
",",
"transmat",
")",
"# Multi-Step simulation",
"out",
"=",
"np",
".",
"... | Simulate the next state
Parameters
----------
s0 : ndarray
Vector with state variables at t=0
transmat : ndarray
The estimated transition/stochastic matrix.
steps : int
(Default: 1) The number of steps to simulate model outputs ahead.
If steps>1 the a Mult-Step Sim... | [
"Simulate",
"the",
"next",
"state"
] | e30747f797ce777fd2aaa1b7ee5a77e91d7db5e4 | https://github.com/kmedian/ctmc/blob/e30747f797ce777fd2aaa1b7ee5a77e91d7db5e4/ctmc/simulate.py#L5-L40 |
41,526 | RI-imaging/qpformat | qpformat/file_formats/single_npy_numpy.py | SingleNpyNumpy.verify | def verify(path):
"""Verify that `path` has a supported numpy file format"""
path = pathlib.Path(path)
valid = False
if path.suffix == ".npy":
try:
nf = np.load(str(path), mmap_mode="r", allow_pickle=False)
except (OSError, ValueError, IsADirectory... | python | def verify(path):
"""Verify that `path` has a supported numpy file format"""
path = pathlib.Path(path)
valid = False
if path.suffix == ".npy":
try:
nf = np.load(str(path), mmap_mode="r", allow_pickle=False)
except (OSError, ValueError, IsADirectory... | [
"def",
"verify",
"(",
"path",
")",
":",
"path",
"=",
"pathlib",
".",
"Path",
"(",
"path",
")",
"valid",
"=",
"False",
"if",
"path",
".",
"suffix",
"==",
"\".npy\"",
":",
"try",
":",
"nf",
"=",
"np",
".",
"load",
"(",
"str",
"(",
"path",
")",
",... | Verify that `path` has a supported numpy file format | [
"Verify",
"that",
"path",
"has",
"a",
"supported",
"numpy",
"file",
"format"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/single_npy_numpy.py#L46-L58 |
41,527 | greenape/mktheapidocs | mktheapidocs/plugin.py | PyDocFile._get_stem | def _get_stem(self):
""" Return the name of the file without it's extension. """
filename = os.path.basename(self.src_path)
stem, ext = os.path.splitext(filename)
return "index" if stem in ("index", "README", "__init__") else stem | python | def _get_stem(self):
""" Return the name of the file without it's extension. """
filename = os.path.basename(self.src_path)
stem, ext = os.path.splitext(filename)
return "index" if stem in ("index", "README", "__init__") else stem | [
"def",
"_get_stem",
"(",
"self",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"self",
".",
"src_path",
")",
"stem",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"return",
"\"index\"",
"if",
"stem",... | Return the name of the file without it's extension. | [
"Return",
"the",
"name",
"of",
"the",
"file",
"without",
"it",
"s",
"extension",
"."
] | a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7 | https://github.com/greenape/mktheapidocs/blob/a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7/mktheapidocs/plugin.py#L21-L25 |
41,528 | panyam/typecube | typecube/checkers.py | type_check | def type_check(thetype, data, bindings = None):
""" Checks that a given bit of data conforms to the type provided """
if not bindings: bindings = Bindings()
if isinstance(thetype, core.RecordType):
for name,child in zip(thetype.child_names, thetype.child_types):
value = data[name]
... | python | def type_check(thetype, data, bindings = None):
""" Checks that a given bit of data conforms to the type provided """
if not bindings: bindings = Bindings()
if isinstance(thetype, core.RecordType):
for name,child in zip(thetype.child_names, thetype.child_types):
value = data[name]
... | [
"def",
"type_check",
"(",
"thetype",
",",
"data",
",",
"bindings",
"=",
"None",
")",
":",
"if",
"not",
"bindings",
":",
"bindings",
"=",
"Bindings",
"(",
")",
"if",
"isinstance",
"(",
"thetype",
",",
"core",
".",
"RecordType",
")",
":",
"for",
"name",
... | Checks that a given bit of data conforms to the type provided | [
"Checks",
"that",
"a",
"given",
"bit",
"of",
"data",
"conforms",
"to",
"the",
"type",
"provided"
] | e8fa235675b6497acd52c68286bb9e4aefc5c8d1 | https://github.com/panyam/typecube/blob/e8fa235675b6497acd52c68286bb9e4aefc5c8d1/typecube/checkers.py#L41-L92 |
41,529 | danbradham/scrim | scrim/utils.py | parse_setup | def parse_setup(filepath):
'''Get the kwargs from the setup function in setup.py'''
# TODO: Need to parse setup.cfg and merge with the data from below
# Monkey patch setuptools.setup to capture keyword arguments
setup_kwargs = {}
def setup_interceptor(**kwargs):
setup_kwargs.update(kwargs)... | python | def parse_setup(filepath):
'''Get the kwargs from the setup function in setup.py'''
# TODO: Need to parse setup.cfg and merge with the data from below
# Monkey patch setuptools.setup to capture keyword arguments
setup_kwargs = {}
def setup_interceptor(**kwargs):
setup_kwargs.update(kwargs)... | [
"def",
"parse_setup",
"(",
"filepath",
")",
":",
"# TODO: Need to parse setup.cfg and merge with the data from below",
"# Monkey patch setuptools.setup to capture keyword arguments",
"setup_kwargs",
"=",
"{",
"}",
"def",
"setup_interceptor",
"(",
"*",
"*",
"kwargs",
")",
":",
... | Get the kwargs from the setup function in setup.py | [
"Get",
"the",
"kwargs",
"from",
"the",
"setup",
"function",
"in",
"setup",
".",
"py"
] | 982a5db1db6e4ef40267f15642af2c7ea0e803ae | https://github.com/danbradham/scrim/blob/982a5db1db6e4ef40267f15642af2c7ea0e803ae/scrim/utils.py#L79-L101 |
41,530 | danbradham/scrim | scrim/utils.py | get_console_scripts | def get_console_scripts(setup_data):
'''Parse and return a list of console_scripts from setup_data'''
# TODO: support ini format of entry_points
# TODO: support setup.cfg entry_points as available in pbr
if 'entry_points' not in setup_data:
return []
console_scripts = setup_data['entry_po... | python | def get_console_scripts(setup_data):
'''Parse and return a list of console_scripts from setup_data'''
# TODO: support ini format of entry_points
# TODO: support setup.cfg entry_points as available in pbr
if 'entry_points' not in setup_data:
return []
console_scripts = setup_data['entry_po... | [
"def",
"get_console_scripts",
"(",
"setup_data",
")",
":",
"# TODO: support ini format of entry_points",
"# TODO: support setup.cfg entry_points as available in pbr",
"if",
"'entry_points'",
"not",
"in",
"setup_data",
":",
"return",
"[",
"]",
"console_scripts",
"=",
"setup_data... | Parse and return a list of console_scripts from setup_data | [
"Parse",
"and",
"return",
"a",
"list",
"of",
"console_scripts",
"from",
"setup_data"
] | 982a5db1db6e4ef40267f15642af2c7ea0e803ae | https://github.com/danbradham/scrim/blob/982a5db1db6e4ef40267f15642af2c7ea0e803ae/scrim/utils.py#L104-L114 |
41,531 | ponty/confduino | confduino/proginstall.py | install_programmer | def install_programmer(programmer_id, programmer_options, replace_existing=False):
"""install programmer in programmers.txt.
:param programmer_id: string identifier
:param programmer_options: dict like
:param replace_existing: bool
:rtype: None
"""
doaction = 0
if programmer_id in prog... | python | def install_programmer(programmer_id, programmer_options, replace_existing=False):
"""install programmer in programmers.txt.
:param programmer_id: string identifier
:param programmer_options: dict like
:param replace_existing: bool
:rtype: None
"""
doaction = 0
if programmer_id in prog... | [
"def",
"install_programmer",
"(",
"programmer_id",
",",
"programmer_options",
",",
"replace_existing",
"=",
"False",
")",
":",
"doaction",
"=",
"0",
"if",
"programmer_id",
"in",
"programmers",
"(",
")",
".",
"keys",
"(",
")",
":",
"log",
".",
"debug",
"(",
... | install programmer in programmers.txt.
:param programmer_id: string identifier
:param programmer_options: dict like
:param replace_existing: bool
:rtype: None | [
"install",
"programmer",
"in",
"programmers",
".",
"txt",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/proginstall.py#L11-L32 |
41,532 | dps/simplescheduler | simplescheduler/scheduler.py | Scheduler.schedule | def schedule(self, job, when):
""" Schedule job to run at when nanoseconds since the UNIX epoch."""
pjob = pickle.dumps(job)
self._redis.zadd('ss:scheduled', when, pjob) | python | def schedule(self, job, when):
""" Schedule job to run at when nanoseconds since the UNIX epoch."""
pjob = pickle.dumps(job)
self._redis.zadd('ss:scheduled', when, pjob) | [
"def",
"schedule",
"(",
"self",
",",
"job",
",",
"when",
")",
":",
"pjob",
"=",
"pickle",
".",
"dumps",
"(",
"job",
")",
"self",
".",
"_redis",
".",
"zadd",
"(",
"'ss:scheduled'",
",",
"when",
",",
"pjob",
")"
] | Schedule job to run at when nanoseconds since the UNIX epoch. | [
"Schedule",
"job",
"to",
"run",
"at",
"when",
"nanoseconds",
"since",
"the",
"UNIX",
"epoch",
"."
] | d633549a8b78d5c1ff37419f4970835f1c6a5947 | https://github.com/dps/simplescheduler/blob/d633549a8b78d5c1ff37419f4970835f1c6a5947/simplescheduler/scheduler.py#L68-L71 |
41,533 | dps/simplescheduler | simplescheduler/scheduler.py | Scheduler.schedule_in | def schedule_in(self, job, timedelta):
""" Schedule job to run at datetime.timedelta from now."""
now = long(self._now() * 1e6)
when = now + timedelta.total_seconds() * 1e6
self.schedule(job, when) | python | def schedule_in(self, job, timedelta):
""" Schedule job to run at datetime.timedelta from now."""
now = long(self._now() * 1e6)
when = now + timedelta.total_seconds() * 1e6
self.schedule(job, when) | [
"def",
"schedule_in",
"(",
"self",
",",
"job",
",",
"timedelta",
")",
":",
"now",
"=",
"long",
"(",
"self",
".",
"_now",
"(",
")",
"*",
"1e6",
")",
"when",
"=",
"now",
"+",
"timedelta",
".",
"total_seconds",
"(",
")",
"*",
"1e6",
"self",
".",
"sc... | Schedule job to run at datetime.timedelta from now. | [
"Schedule",
"job",
"to",
"run",
"at",
"datetime",
".",
"timedelta",
"from",
"now",
"."
] | d633549a8b78d5c1ff37419f4970835f1c6a5947 | https://github.com/dps/simplescheduler/blob/d633549a8b78d5c1ff37419f4970835f1c6a5947/simplescheduler/scheduler.py#L73-L77 |
41,534 | dps/simplescheduler | simplescheduler/scheduler.py | Scheduler.schedule_now | def schedule_now(self, job):
""" Schedule job to run as soon as possible."""
now = long(self._now() * 1e6)
self.schedule(job, now) | python | def schedule_now(self, job):
""" Schedule job to run as soon as possible."""
now = long(self._now() * 1e6)
self.schedule(job, now) | [
"def",
"schedule_now",
"(",
"self",
",",
"job",
")",
":",
"now",
"=",
"long",
"(",
"self",
".",
"_now",
"(",
")",
"*",
"1e6",
")",
"self",
".",
"schedule",
"(",
"job",
",",
"now",
")"
] | Schedule job to run as soon as possible. | [
"Schedule",
"job",
"to",
"run",
"as",
"soon",
"as",
"possible",
"."
] | d633549a8b78d5c1ff37419f4970835f1c6a5947 | https://github.com/dps/simplescheduler/blob/d633549a8b78d5c1ff37419f4970835f1c6a5947/simplescheduler/scheduler.py#L79-L82 |
41,535 | hatemile/hatemile-for-python | hatemile/implementation/form.py | AccessibleFormImplementation._get_aria_autocomplete | def _get_aria_autocomplete(self, field):
"""
Returns the appropriate value for attribute aria-autocomplete of field.
:param field: The field.
:type field: hatemile.util.html.htmldomelement.HTMLDOMElement
:return: The ARIA value of field.
:rtype: str
"""
... | python | def _get_aria_autocomplete(self, field):
"""
Returns the appropriate value for attribute aria-autocomplete of field.
:param field: The field.
:type field: hatemile.util.html.htmldomelement.HTMLDOMElement
:return: The ARIA value of field.
:rtype: str
"""
... | [
"def",
"_get_aria_autocomplete",
"(",
"self",
",",
"field",
")",
":",
"tag_name",
"=",
"field",
".",
"get_tag_name",
"(",
")",
"input_type",
"=",
"None",
"if",
"field",
".",
"has_attribute",
"(",
"'type'",
")",
":",
"input_type",
"=",
"field",
".",
"get_at... | Returns the appropriate value for attribute aria-autocomplete of field.
:param field: The field.
:type field: hatemile.util.html.htmldomelement.HTMLDOMElement
:return: The ARIA value of field.
:rtype: str | [
"Returns",
"the",
"appropriate",
"value",
"for",
"attribute",
"aria",
"-",
"autocomplete",
"of",
"field",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/form.py#L89-L143 |
41,536 | hatemile/hatemile-for-python | hatemile/implementation/form.py | AccessibleFormImplementation._validate | def _validate(self, field, list_attribute):
"""
Validate the field when its value change.
:param field: The field.
:param list_attribute: The list attribute of field with validation.
"""
if not self.scripts_added:
self._generate_validation_scripts()
... | python | def _validate(self, field, list_attribute):
"""
Validate the field when its value change.
:param field: The field.
:param list_attribute: The list attribute of field with validation.
"""
if not self.scripts_added:
self._generate_validation_scripts()
... | [
"def",
"_validate",
"(",
"self",
",",
"field",
",",
"list_attribute",
")",
":",
"if",
"not",
"self",
".",
"scripts_added",
":",
"self",
".",
"_generate_validation_scripts",
"(",
")",
"self",
".",
"id_generator",
".",
"generate_id",
"(",
"field",
")",
"self",... | Validate the field when its value change.
:param field: The field.
:param list_attribute: The list attribute of field with validation. | [
"Validate",
"the",
"field",
"when",
"its",
"value",
"change",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/form.py#L250-L267 |
41,537 | yougov/vr.common | vr/common/slugignore.py | remove | def remove(item):
"""
Delete item, whether it's a file, a folder, or a folder
full of other files and folders.
"""
if os.path.isdir(item):
shutil.rmtree(item)
else:
# Assume it's a file. error if not.
os.remove(item) | python | def remove(item):
"""
Delete item, whether it's a file, a folder, or a folder
full of other files and folders.
"""
if os.path.isdir(item):
shutil.rmtree(item)
else:
# Assume it's a file. error if not.
os.remove(item) | [
"def",
"remove",
"(",
"item",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"item",
")",
":",
"shutil",
".",
"rmtree",
"(",
"item",
")",
"else",
":",
"# Assume it's a file. error if not.",
"os",
".",
"remove",
"(",
"item",
")"
] | Delete item, whether it's a file, a folder, or a folder
full of other files and folders. | [
"Delete",
"item",
"whether",
"it",
"s",
"a",
"file",
"a",
"folder",
"or",
"a",
"folder",
"full",
"of",
"other",
"files",
"and",
"folders",
"."
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/slugignore.py#L32-L41 |
41,538 | yougov/vr.common | vr/common/slugignore.py | get_slugignores | def get_slugignores(root, fname='.slugignore'):
"""
Given a root path, read any .slugignore file inside and return a list of
patterns that should be removed prior to slug compilation.
Return empty list if file does not exist.
"""
try:
with open(os.path.join(root, fname)) as f:
... | python | def get_slugignores(root, fname='.slugignore'):
"""
Given a root path, read any .slugignore file inside and return a list of
patterns that should be removed prior to slug compilation.
Return empty list if file does not exist.
"""
try:
with open(os.path.join(root, fname)) as f:
... | [
"def",
"get_slugignores",
"(",
"root",
",",
"fname",
"=",
"'.slugignore'",
")",
":",
"try",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"fname",
")",
")",
"as",
"f",
":",
"return",
"[",
"l",
".",
"rstrip",
"(",
"'\... | Given a root path, read any .slugignore file inside and return a list of
patterns that should be removed prior to slug compilation.
Return empty list if file does not exist. | [
"Given",
"a",
"root",
"path",
"read",
"any",
".",
"slugignore",
"file",
"inside",
"and",
"return",
"a",
"list",
"of",
"patterns",
"that",
"should",
"be",
"removed",
"prior",
"to",
"slug",
"compilation",
"."
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/slugignore.py#L64-L75 |
41,539 | yougov/vr.common | vr/common/slugignore.py | clean_slug_dir | def clean_slug_dir(root):
"""
Given a path, delete anything specified in .slugignore.
"""
if not root.endswith('/'):
root += '/'
for pattern in get_slugignores(root):
print("pattern", pattern)
remove_pattern(root, pattern) | python | def clean_slug_dir(root):
"""
Given a path, delete anything specified in .slugignore.
"""
if not root.endswith('/'):
root += '/'
for pattern in get_slugignores(root):
print("pattern", pattern)
remove_pattern(root, pattern) | [
"def",
"clean_slug_dir",
"(",
"root",
")",
":",
"if",
"not",
"root",
".",
"endswith",
"(",
"'/'",
")",
":",
"root",
"+=",
"'/'",
"for",
"pattern",
"in",
"get_slugignores",
"(",
"root",
")",
":",
"print",
"(",
"\"pattern\"",
",",
"pattern",
")",
"remove... | Given a path, delete anything specified in .slugignore. | [
"Given",
"a",
"path",
"delete",
"anything",
"specified",
"in",
".",
"slugignore",
"."
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/slugignore.py#L78-L86 |
41,540 | asascience-open/paegan-transport | paegan/transport/model_controller.py | ModelController.export | def export(self, folder_path, format=None):
"""
General purpose export method, gets file type
from filepath extension
Valid output formats currently are:
Trackline: trackline or trkl or *.trkl
Shapefile: shapefile or shape or shp or *.shp
... | python | def export(self, folder_path, format=None):
"""
General purpose export method, gets file type
from filepath extension
Valid output formats currently are:
Trackline: trackline or trkl or *.trkl
Shapefile: shapefile or shape or shp or *.shp
... | [
"def",
"export",
"(",
"self",
",",
"folder_path",
",",
"format",
"=",
"None",
")",
":",
"if",
"format",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Must export to a specific format, no format specified.\"",
")",
"format",
"=",
"format",
".",
"lower",
"(",
... | General purpose export method, gets file type
from filepath extension
Valid output formats currently are:
Trackline: trackline or trkl or *.trkl
Shapefile: shapefile or shape or shp or *.shp
NetCDF: netcdf or nc or *.nc | [
"General",
"purpose",
"export",
"method",
"gets",
"file",
"type",
"from",
"filepath",
"extension"
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/model_controller.py#L562-L585 |
41,541 | puhitaku/naam | naam/__init__.py | _parse | def _parse(args):
"""Parse passed arguments from shell."""
ordered = []
opt_full = dict()
opt_abbrev = dict()
args = args + [''] # Avoid out of range
i = 0
while i < len(args) - 1:
arg = args[i]
arg_next = args[i+1]
if arg.startswith('--'):
if arg_next... | python | def _parse(args):
"""Parse passed arguments from shell."""
ordered = []
opt_full = dict()
opt_abbrev = dict()
args = args + [''] # Avoid out of range
i = 0
while i < len(args) - 1:
arg = args[i]
arg_next = args[i+1]
if arg.startswith('--'):
if arg_next... | [
"def",
"_parse",
"(",
"args",
")",
":",
"ordered",
"=",
"[",
"]",
"opt_full",
"=",
"dict",
"(",
")",
"opt_abbrev",
"=",
"dict",
"(",
")",
"args",
"=",
"args",
"+",
"[",
"''",
"]",
"# Avoid out of range",
"i",
"=",
"0",
"while",
"i",
"<",
"len",
"... | Parse passed arguments from shell. | [
"Parse",
"passed",
"arguments",
"from",
"shell",
"."
] | 20dd01af4d85c9c88963ea1b78a6f217cb015f27 | https://github.com/puhitaku/naam/blob/20dd01af4d85c9c88963ea1b78a6f217cb015f27/naam/__init__.py#L9-L38 |
41,542 | puhitaku/naam | naam/__init__.py | _construct_optional | def _construct_optional(params):
"""Construct optional args' key and abbreviated key from signature."""
args = []
filtered = {key: arg.default for key, arg in params.items() if arg.default != inspect._empty}
for key, default in filtered.items():
arg = OptionalArg(full=key, abbrev=key[0].lower()... | python | def _construct_optional(params):
"""Construct optional args' key and abbreviated key from signature."""
args = []
filtered = {key: arg.default for key, arg in params.items() if arg.default != inspect._empty}
for key, default in filtered.items():
arg = OptionalArg(full=key, abbrev=key[0].lower()... | [
"def",
"_construct_optional",
"(",
"params",
")",
":",
"args",
"=",
"[",
"]",
"filtered",
"=",
"{",
"key",
":",
"arg",
".",
"default",
"for",
"key",
",",
"arg",
"in",
"params",
".",
"items",
"(",
")",
"if",
"arg",
".",
"default",
"!=",
"inspect",
"... | Construct optional args' key and abbreviated key from signature. | [
"Construct",
"optional",
"args",
"key",
"and",
"abbreviated",
"key",
"from",
"signature",
"."
] | 20dd01af4d85c9c88963ea1b78a6f217cb015f27 | https://github.com/puhitaku/naam/blob/20dd01af4d85c9c88963ea1b78a6f217cb015f27/naam/__init__.py#L46-L73 |
41,543 | hatemile/hatemile-for-python | hatemile/implementation/event.py | AccessibleEventImplementation._keyboard_access | def _keyboard_access(self, element):
"""
Provide keyboard access for element, if it not has.
:param element: The element.
:type element: hatemile.util.html.htmldomelement.HTMLDOMElement
"""
# pylint: disable=no-self-use
if not element.has_attribute('tabindex'):
... | python | def _keyboard_access(self, element):
"""
Provide keyboard access for element, if it not has.
:param element: The element.
:type element: hatemile.util.html.htmldomelement.HTMLDOMElement
"""
# pylint: disable=no-self-use
if not element.has_attribute('tabindex'):
... | [
"def",
"_keyboard_access",
"(",
"self",
",",
"element",
")",
":",
"# pylint: disable=no-self-use",
"if",
"not",
"element",
".",
"has_attribute",
"(",
"'tabindex'",
")",
":",
"tag",
"=",
"element",
".",
"get_tag_name",
"(",
")",
"if",
"(",
"tag",
"==",
"'A'",... | Provide keyboard access for element, if it not has.
:param element: The element.
:type element: hatemile.util.html.htmldomelement.HTMLDOMElement | [
"Provide",
"keyboard",
"access",
"for",
"element",
"if",
"it",
"not",
"has",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/event.py#L61-L81 |
41,544 | hatemile/hatemile-for-python | hatemile/implementation/event.py | AccessibleEventImplementation._add_event_in_element | def _add_event_in_element(self, element, event):
"""
Add a type of event in element.
:param element: The element.
:type element: hatemile.util.html.htmldomelement.HTMLDOMElement
:param event: The type of event.
:type event: str
"""
if not self.main_scrip... | python | def _add_event_in_element(self, element, event):
"""
Add a type of event in element.
:param element: The element.
:type element: hatemile.util.html.htmldomelement.HTMLDOMElement
:param event: The type of event.
:type event: str
"""
if not self.main_scrip... | [
"def",
"_add_event_in_element",
"(",
"self",
",",
"element",
",",
"event",
")",
":",
"if",
"not",
"self",
".",
"main_script_added",
":",
"self",
".",
"_generate_main_scripts",
"(",
")",
"if",
"self",
".",
"script_list",
"is",
"not",
"None",
":",
"self",
".... | Add a type of event in element.
:param element: The element.
:type element: hatemile.util.html.htmldomelement.HTMLDOMElement
:param event: The type of event.
:type event: str | [
"Add",
"a",
"type",
"of",
"event",
"in",
"element",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/event.py#L191-L211 |
41,545 | Jarn/jarn.mkrelease | jarn/mkrelease/tee.py | tee | def tee(process, filter):
"""Read lines from process.stdout and echo them to sys.stdout.
Returns a list of lines read. Lines are not newline terminated.
The 'filter' is a callable which is invoked for every line,
receiving the line as argument. If the filter returns True, the
line is echoed to sys... | python | def tee(process, filter):
"""Read lines from process.stdout and echo them to sys.stdout.
Returns a list of lines read. Lines are not newline terminated.
The 'filter' is a callable which is invoked for every line,
receiving the line as argument. If the filter returns True, the
line is echoed to sys... | [
"def",
"tee",
"(",
"process",
",",
"filter",
")",
":",
"lines",
"=",
"[",
"]",
"while",
"True",
":",
"line",
"=",
"process",
".",
"stdout",
".",
"readline",
"(",
")",
"if",
"line",
":",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
">=",
"3",
... | Read lines from process.stdout and echo them to sys.stdout.
Returns a list of lines read. Lines are not newline terminated.
The 'filter' is a callable which is invoked for every line,
receiving the line as argument. If the filter returns True, the
line is echoed to sys.stdout. | [
"Read",
"lines",
"from",
"process",
".",
"stdout",
"and",
"echo",
"them",
"to",
"sys",
".",
"stdout",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/tee.py#L19-L42 |
41,546 | Jarn/jarn.mkrelease | jarn/mkrelease/tee.py | tee2 | def tee2(process, filter):
"""Read lines from process.stderr and echo them to sys.stderr.
The 'filter' is a callable which is invoked for every line,
receiving the line as argument. If the filter returns True, the
line is echoed to sys.stderr.
"""
while True:
line = process.stderr.readl... | python | def tee2(process, filter):
"""Read lines from process.stderr and echo them to sys.stderr.
The 'filter' is a callable which is invoked for every line,
receiving the line as argument. If the filter returns True, the
line is echoed to sys.stderr.
"""
while True:
line = process.stderr.readl... | [
"def",
"tee2",
"(",
"process",
",",
"filter",
")",
":",
"while",
"True",
":",
"line",
"=",
"process",
".",
"stderr",
".",
"readline",
"(",
")",
"if",
"line",
":",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
">=",
"3",
":",
"line",
"=",
"deco... | Read lines from process.stderr and echo them to sys.stderr.
The 'filter' is a callable which is invoked for every line,
receiving the line as argument. If the filter returns True, the
line is echoed to sys.stderr. | [
"Read",
"lines",
"from",
"process",
".",
"stderr",
"and",
"echo",
"them",
"to",
"sys",
".",
"stderr",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/tee.py#L45-L62 |
41,547 | Jarn/jarn.mkrelease | jarn/mkrelease/tee.py | run | def run(args, echo=True, echo2=True, shell=False, cwd=None, env=None):
"""Run 'args' and return a two-tuple of exit code and lines read.
If 'echo' is True, the stdout stream is echoed to sys.stdout.
If 'echo2' is True, the stderr stream is echoed to sys.stderr.
The 'echo' and 'echo2' arguments may be ... | python | def run(args, echo=True, echo2=True, shell=False, cwd=None, env=None):
"""Run 'args' and return a two-tuple of exit code and lines read.
If 'echo' is True, the stdout stream is echoed to sys.stdout.
If 'echo2' is True, the stderr stream is echoed to sys.stderr.
The 'echo' and 'echo2' arguments may be ... | [
"def",
"run",
"(",
"args",
",",
"echo",
"=",
"True",
",",
"echo2",
"=",
"True",
",",
"shell",
"=",
"False",
",",
"cwd",
"=",
"None",
",",
"env",
"=",
"None",
")",
":",
"if",
"not",
"callable",
"(",
"echo",
")",
":",
"echo",
"=",
"On",
"(",
")... | Run 'args' and return a two-tuple of exit code and lines read.
If 'echo' is True, the stdout stream is echoed to sys.stdout.
If 'echo2' is True, the stderr stream is echoed to sys.stderr.
The 'echo' and 'echo2' arguments may be callables, in which
case they are used as tee filters.
If 'shell' is ... | [
"Run",
"args",
"and",
"return",
"a",
"two",
"-",
"tuple",
"of",
"exit",
"code",
"and",
"lines",
"read",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/tee.py#L81-L112 |
41,548 | helixyte/everest | everest/representers/registry.py | RepresenterRegistry.register_representer_class | def register_representer_class(self, representer_class):
"""
Registers the given representer class with this registry, using
its MIME content type as the key.
"""
if representer_class in self.__rpr_classes.values():
raise ValueError('The representer class "%s" has alr... | python | def register_representer_class(self, representer_class):
"""
Registers the given representer class with this registry, using
its MIME content type as the key.
"""
if representer_class in self.__rpr_classes.values():
raise ValueError('The representer class "%s" has alr... | [
"def",
"register_representer_class",
"(",
"self",
",",
"representer_class",
")",
":",
"if",
"representer_class",
"in",
"self",
".",
"__rpr_classes",
".",
"values",
"(",
")",
":",
"raise",
"ValueError",
"(",
"'The representer class \"%s\" has already been '",
"'registere... | Registers the given representer class with this registry, using
its MIME content type as the key. | [
"Registers",
"the",
"given",
"representer",
"class",
"with",
"this",
"registry",
"using",
"its",
"MIME",
"content",
"type",
"as",
"the",
"key",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/registry.py#L28-L41 |
41,549 | helixyte/everest | everest/representers/registry.py | RepresenterRegistry.register | def register(self, resource_class, content_type, configuration=None):
"""
Registers a representer factory for the given combination of resource
class and content type.
:param configuration: representer configuration. A default instance
will be created if this is not given.
... | python | def register(self, resource_class, content_type, configuration=None):
"""
Registers a representer factory for the given combination of resource
class and content type.
:param configuration: representer configuration. A default instance
will be created if this is not given.
... | [
"def",
"register",
"(",
"self",
",",
"resource_class",
",",
"content_type",
",",
"configuration",
"=",
"None",
")",
":",
"if",
"not",
"issubclass",
"(",
"resource_class",
",",
"Resource",
")",
":",
"raise",
"ValueError",
"(",
"'Representers can only be registered ... | Registers a representer factory for the given combination of resource
class and content type.
:param configuration: representer configuration. A default instance
will be created if this is not given.
:type configuration:
:class:`everest.representers.config.RepresenterConfi... | [
"Registers",
"a",
"representer",
"factory",
"for",
"the",
"given",
"combination",
"of",
"resource",
"class",
"and",
"content",
"type",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/registry.py#L62-L112 |
41,550 | helixyte/everest | everest/representers/registry.py | RepresenterRegistry.create | def create(self, resource_class, content_type):
"""
Creates a representer for the given combination of resource and
content type. This will also find representer factories that were
registered for a base class of the given resource.
"""
rpr_fac = self.__find_representer_f... | python | def create(self, resource_class, content_type):
"""
Creates a representer for the given combination of resource and
content type. This will also find representer factories that were
registered for a base class of the given resource.
"""
rpr_fac = self.__find_representer_f... | [
"def",
"create",
"(",
"self",
",",
"resource_class",
",",
"content_type",
")",
":",
"rpr_fac",
"=",
"self",
".",
"__find_representer_factory",
"(",
"resource_class",
",",
"content_type",
")",
"if",
"rpr_fac",
"is",
"None",
":",
"# Register a representer with default... | Creates a representer for the given combination of resource and
content type. This will also find representer factories that were
registered for a base class of the given resource. | [
"Creates",
"a",
"representer",
"for",
"the",
"given",
"combination",
"of",
"resource",
"and",
"content",
"type",
".",
"This",
"will",
"also",
"find",
"representer",
"factories",
"that",
"were",
"registered",
"for",
"a",
"base",
"class",
"of",
"the",
"given",
... | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/registry.py#L114-L128 |
41,551 | blockstack-packages/blockstack-gpg | blockstack_gpg/gpg.py | make_gpg_home | def make_gpg_home(appname, config_dir=None):
"""
Make GPG keyring dir for a particular application.
Return the path.
"""
assert is_valid_appname(appname)
config_dir = get_config_dir( config_dir )
path = os.path.join( config_dir, "gpgkeys", appname )
if not os.path.exists(path):
... | python | def make_gpg_home(appname, config_dir=None):
"""
Make GPG keyring dir for a particular application.
Return the path.
"""
assert is_valid_appname(appname)
config_dir = get_config_dir( config_dir )
path = os.path.join( config_dir, "gpgkeys", appname )
if not os.path.exists(path):
... | [
"def",
"make_gpg_home",
"(",
"appname",
",",
"config_dir",
"=",
"None",
")",
":",
"assert",
"is_valid_appname",
"(",
"appname",
")",
"config_dir",
"=",
"get_config_dir",
"(",
"config_dir",
")",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"config_dir",
... | Make GPG keyring dir for a particular application.
Return the path. | [
"Make",
"GPG",
"keyring",
"dir",
"for",
"a",
"particular",
"application",
".",
"Return",
"the",
"path",
"."
] | e4d51e4e51678d9b946596ca9dec53e2d78c8710 | https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L87-L102 |
41,552 | blockstack-packages/blockstack-gpg | blockstack_gpg/gpg.py | get_gpg_home | def get_gpg_home( appname, config_dir=None ):
"""
Get the GPG keyring directory for a particular application.
Return the path.
"""
assert is_valid_appname(appname)
config_dir = get_config_dir( config_dir )
path = os.path.join( config_dir, "gpgkeys", appname )
return path | python | def get_gpg_home( appname, config_dir=None ):
"""
Get the GPG keyring directory for a particular application.
Return the path.
"""
assert is_valid_appname(appname)
config_dir = get_config_dir( config_dir )
path = os.path.join( config_dir, "gpgkeys", appname )
return path | [
"def",
"get_gpg_home",
"(",
"appname",
",",
"config_dir",
"=",
"None",
")",
":",
"assert",
"is_valid_appname",
"(",
"appname",
")",
"config_dir",
"=",
"get_config_dir",
"(",
"config_dir",
")",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"config_dir",
... | Get the GPG keyring directory for a particular application.
Return the path. | [
"Get",
"the",
"GPG",
"keyring",
"directory",
"for",
"a",
"particular",
"application",
".",
"Return",
"the",
"path",
"."
] | e4d51e4e51678d9b946596ca9dec53e2d78c8710 | https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L105-L113 |
41,553 | blockstack-packages/blockstack-gpg | blockstack_gpg/gpg.py | make_gpg_tmphome | def make_gpg_tmphome( prefix=None, config_dir=None ):
"""
Make a temporary directory to hold GPG keys that are not
going to be stored to the application's keyring.
"""
if prefix is None:
prefix = "tmp"
config_dir = get_config_dir( config_dir )
tmppath = os.path.join( config_dir, "t... | python | def make_gpg_tmphome( prefix=None, config_dir=None ):
"""
Make a temporary directory to hold GPG keys that are not
going to be stored to the application's keyring.
"""
if prefix is None:
prefix = "tmp"
config_dir = get_config_dir( config_dir )
tmppath = os.path.join( config_dir, "t... | [
"def",
"make_gpg_tmphome",
"(",
"prefix",
"=",
"None",
",",
"config_dir",
"=",
"None",
")",
":",
"if",
"prefix",
"is",
"None",
":",
"prefix",
"=",
"\"tmp\"",
"config_dir",
"=",
"get_config_dir",
"(",
"config_dir",
")",
"tmppath",
"=",
"os",
".",
"path",
... | Make a temporary directory to hold GPG keys that are not
going to be stored to the application's keyring. | [
"Make",
"a",
"temporary",
"directory",
"to",
"hold",
"GPG",
"keys",
"that",
"are",
"not",
"going",
"to",
"be",
"stored",
"to",
"the",
"application",
"s",
"keyring",
"."
] | e4d51e4e51678d9b946596ca9dec53e2d78c8710 | https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L125-L139 |
41,554 | blockstack-packages/blockstack-gpg | blockstack_gpg/gpg.py | gpg_stash_key | def gpg_stash_key( appname, key_bin, config_dir=None, gpghome=None ):
"""
Store a key locally to our app keyring.
Does NOT put it into a blockchain ID
Return the key ID on success
Return None on error
"""
assert is_valid_appname(appname)
key_bin = str(key_bin)
assert len(key_bin) > ... | python | def gpg_stash_key( appname, key_bin, config_dir=None, gpghome=None ):
"""
Store a key locally to our app keyring.
Does NOT put it into a blockchain ID
Return the key ID on success
Return None on error
"""
assert is_valid_appname(appname)
key_bin = str(key_bin)
assert len(key_bin) > ... | [
"def",
"gpg_stash_key",
"(",
"appname",
",",
"key_bin",
",",
"config_dir",
"=",
"None",
",",
"gpghome",
"=",
"None",
")",
":",
"assert",
"is_valid_appname",
"(",
"appname",
")",
"key_bin",
"=",
"str",
"(",
"key_bin",
")",
"assert",
"len",
"(",
"key_bin",
... | Store a key locally to our app keyring.
Does NOT put it into a blockchain ID
Return the key ID on success
Return None on error | [
"Store",
"a",
"key",
"locally",
"to",
"our",
"app",
"keyring",
".",
"Does",
"NOT",
"put",
"it",
"into",
"a",
"blockchain",
"ID",
"Return",
"the",
"key",
"ID",
"on",
"success",
"Return",
"None",
"on",
"error"
] | e4d51e4e51678d9b946596ca9dec53e2d78c8710 | https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L142-L172 |
41,555 | blockstack-packages/blockstack-gpg | blockstack_gpg/gpg.py | gpg_unstash_key | def gpg_unstash_key( appname, key_id, config_dir=None, gpghome=None ):
"""
Remove a public key locally from our local app keyring
Return True on success
Return False on error
"""
assert is_valid_appname(appname)
if gpghome is None:
config_dir = get_config_dir( config_dir )
k... | python | def gpg_unstash_key( appname, key_id, config_dir=None, gpghome=None ):
"""
Remove a public key locally from our local app keyring
Return True on success
Return False on error
"""
assert is_valid_appname(appname)
if gpghome is None:
config_dir = get_config_dir( config_dir )
k... | [
"def",
"gpg_unstash_key",
"(",
"appname",
",",
"key_id",
",",
"config_dir",
"=",
"None",
",",
"gpghome",
"=",
"None",
")",
":",
"assert",
"is_valid_appname",
"(",
"appname",
")",
"if",
"gpghome",
"is",
"None",
":",
"config_dir",
"=",
"get_config_dir",
"(",
... | Remove a public key locally from our local app keyring
Return True on success
Return False on error | [
"Remove",
"a",
"public",
"key",
"locally",
"from",
"our",
"local",
"app",
"keyring",
"Return",
"True",
"on",
"success",
"Return",
"False",
"on",
"error"
] | e4d51e4e51678d9b946596ca9dec53e2d78c8710 | https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L175-L203 |
41,556 | blockstack-packages/blockstack-gpg | blockstack_gpg/gpg.py | gpg_download_key | def gpg_download_key( key_id, key_server, config_dir=None ):
"""
Download a GPG key from a key server.
Do not import it into any keyrings.
Return the ASCII-armored key
"""
config_dir = get_config_dir( config_dir )
tmpdir = make_gpg_tmphome( prefix="download", config_dir=config_dir )
gpg... | python | def gpg_download_key( key_id, key_server, config_dir=None ):
"""
Download a GPG key from a key server.
Do not import it into any keyrings.
Return the ASCII-armored key
"""
config_dir = get_config_dir( config_dir )
tmpdir = make_gpg_tmphome( prefix="download", config_dir=config_dir )
gpg... | [
"def",
"gpg_download_key",
"(",
"key_id",
",",
"key_server",
",",
"config_dir",
"=",
"None",
")",
":",
"config_dir",
"=",
"get_config_dir",
"(",
"config_dir",
")",
"tmpdir",
"=",
"make_gpg_tmphome",
"(",
"prefix",
"=",
"\"download\"",
",",
"config_dir",
"=",
"... | Download a GPG key from a key server.
Do not import it into any keyrings.
Return the ASCII-armored key | [
"Download",
"a",
"GPG",
"key",
"from",
"a",
"key",
"server",
".",
"Do",
"not",
"import",
"it",
"into",
"any",
"keyrings",
".",
"Return",
"the",
"ASCII",
"-",
"armored",
"key"
] | e4d51e4e51678d9b946596ca9dec53e2d78c8710 | https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L206-L232 |
41,557 | blockstack-packages/blockstack-gpg | blockstack_gpg/gpg.py | gpg_key_fingerprint | def gpg_key_fingerprint( key_data, config_dir=None ):
"""
Get the key ID of a given serialized key
Return the fingerprint on success
Return None on error
"""
key_data = str(key_data)
config_dir = get_config_dir( config_dir )
tmpdir = make_gpg_tmphome( prefix="key_id-", config_dir=confi... | python | def gpg_key_fingerprint( key_data, config_dir=None ):
"""
Get the key ID of a given serialized key
Return the fingerprint on success
Return None on error
"""
key_data = str(key_data)
config_dir = get_config_dir( config_dir )
tmpdir = make_gpg_tmphome( prefix="key_id-", config_dir=confi... | [
"def",
"gpg_key_fingerprint",
"(",
"key_data",
",",
"config_dir",
"=",
"None",
")",
":",
"key_data",
"=",
"str",
"(",
"key_data",
")",
"config_dir",
"=",
"get_config_dir",
"(",
"config_dir",
")",
"tmpdir",
"=",
"make_gpg_tmphome",
"(",
"prefix",
"=",
"\"key_id... | Get the key ID of a given serialized key
Return the fingerprint on success
Return None on error | [
"Get",
"the",
"key",
"ID",
"of",
"a",
"given",
"serialized",
"key",
"Return",
"the",
"fingerprint",
"on",
"success",
"Return",
"None",
"on",
"error"
] | e4d51e4e51678d9b946596ca9dec53e2d78c8710 | https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L235-L258 |
41,558 | blockstack-packages/blockstack-gpg | blockstack_gpg/gpg.py | gpg_verify_key | def gpg_verify_key( key_id, key_data, config_dir=None ):
"""
Verify that a given serialized key, when imported, has the given key ID.
Return True on success
Return False on error
"""
key_data = str(key_data)
config_dir = get_config_dir( config_dir )
sanitized_key_id = "".join( key_id.u... | python | def gpg_verify_key( key_id, key_data, config_dir=None ):
"""
Verify that a given serialized key, when imported, has the given key ID.
Return True on success
Return False on error
"""
key_data = str(key_data)
config_dir = get_config_dir( config_dir )
sanitized_key_id = "".join( key_id.u... | [
"def",
"gpg_verify_key",
"(",
"key_id",
",",
"key_data",
",",
"config_dir",
"=",
"None",
")",
":",
"key_data",
"=",
"str",
"(",
"key_data",
")",
"config_dir",
"=",
"get_config_dir",
"(",
"config_dir",
")",
"sanitized_key_id",
"=",
"\"\"",
".",
"join",
"(",
... | Verify that a given serialized key, when imported, has the given key ID.
Return True on success
Return False on error | [
"Verify",
"that",
"a",
"given",
"serialized",
"key",
"when",
"imported",
"has",
"the",
"given",
"key",
"ID",
".",
"Return",
"True",
"on",
"success",
"Return",
"False",
"on",
"error"
] | e4d51e4e51678d9b946596ca9dec53e2d78c8710 | https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L261-L287 |
41,559 | blockstack-packages/blockstack-gpg | blockstack_gpg/gpg.py | gpg_export_key | def gpg_export_key( appname, key_id, config_dir=None, include_private=False ):
"""
Get the ASCII-armored key, given the ID
"""
assert is_valid_appname(appname)
config_dir = get_config_dir( config_dir )
keydir = get_gpg_home( appname, config_dir=config_dir )
gpg = gnupg.GPG( homedir=keydir )... | python | def gpg_export_key( appname, key_id, config_dir=None, include_private=False ):
"""
Get the ASCII-armored key, given the ID
"""
assert is_valid_appname(appname)
config_dir = get_config_dir( config_dir )
keydir = get_gpg_home( appname, config_dir=config_dir )
gpg = gnupg.GPG( homedir=keydir )... | [
"def",
"gpg_export_key",
"(",
"appname",
",",
"key_id",
",",
"config_dir",
"=",
"None",
",",
"include_private",
"=",
"False",
")",
":",
"assert",
"is_valid_appname",
"(",
"appname",
")",
"config_dir",
"=",
"get_config_dir",
"(",
"config_dir",
")",
"keydir",
"=... | Get the ASCII-armored key, given the ID | [
"Get",
"the",
"ASCII",
"-",
"armored",
"key",
"given",
"the",
"ID"
] | e4d51e4e51678d9b946596ca9dec53e2d78c8710 | https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L290-L305 |
41,560 | blockstack-packages/blockstack-gpg | blockstack_gpg/gpg.py | gpg_fetch_key | def gpg_fetch_key( key_url, key_id=None, config_dir=None ):
"""
Fetch a GPG public key from the given URL.
Supports anything urllib2 supports.
If the URL has no scheme, then assume it's a PGP key server, and use GPG to go get it.
The key is not accepted into any keyrings.
Return the key data on ... | python | def gpg_fetch_key( key_url, key_id=None, config_dir=None ):
"""
Fetch a GPG public key from the given URL.
Supports anything urllib2 supports.
If the URL has no scheme, then assume it's a PGP key server, and use GPG to go get it.
The key is not accepted into any keyrings.
Return the key data on ... | [
"def",
"gpg_fetch_key",
"(",
"key_url",
",",
"key_id",
"=",
"None",
",",
"config_dir",
"=",
"None",
")",
":",
"dat",
"=",
"None",
"from_blockstack",
"=",
"False",
"# make sure it's valid ",
"try",
":",
"urlparse",
".",
"urlparse",
"(",
"key_url",
")",
"excep... | Fetch a GPG public key from the given URL.
Supports anything urllib2 supports.
If the URL has no scheme, then assume it's a PGP key server, and use GPG to go get it.
The key is not accepted into any keyrings.
Return the key data on success. If key_id is given, verify the key matches.
Return None on... | [
"Fetch",
"a",
"GPG",
"public",
"key",
"from",
"the",
"given",
"URL",
".",
"Supports",
"anything",
"urllib2",
"supports",
".",
"If",
"the",
"URL",
"has",
"no",
"scheme",
"then",
"assume",
"it",
"s",
"a",
"PGP",
"key",
"server",
"and",
"use",
"GPG",
"to"... | e4d51e4e51678d9b946596ca9dec53e2d78c8710 | https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L399-L488 |
41,561 | blockstack-packages/blockstack-gpg | blockstack_gpg/gpg.py | gpg_app_put_key | def gpg_app_put_key( blockchain_id, appname, keyname, key_data, txid=None, immutable=False, proxy=None, wallet_keys=None, config_dir=None ):
"""
Put an application GPG key.
Stash the private key locally to an app-specific keyring.
Return {'status': True, 'key_url': ..., 'key_data': ...} on success
... | python | def gpg_app_put_key( blockchain_id, appname, keyname, key_data, txid=None, immutable=False, proxy=None, wallet_keys=None, config_dir=None ):
"""
Put an application GPG key.
Stash the private key locally to an app-specific keyring.
Return {'status': True, 'key_url': ..., 'key_data': ...} on success
... | [
"def",
"gpg_app_put_key",
"(",
"blockchain_id",
",",
"appname",
",",
"keyname",
",",
"key_data",
",",
"txid",
"=",
"None",
",",
"immutable",
"=",
"False",
",",
"proxy",
"=",
"None",
",",
"wallet_keys",
"=",
"None",
",",
"config_dir",
"=",
"None",
")",
":... | Put an application GPG key.
Stash the private key locally to an app-specific keyring.
Return {'status': True, 'key_url': ..., 'key_data': ...} on success
Return {'error': ...} on error
If immutable is True, then store the data as an immutable entry (e.g. update the zonefile with the key hash)
... | [
"Put",
"an",
"application",
"GPG",
"key",
".",
"Stash",
"the",
"private",
"key",
"locally",
"to",
"an",
"app",
"-",
"specific",
"keyring",
"."
] | e4d51e4e51678d9b946596ca9dec53e2d78c8710 | https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L703-L759 |
41,562 | blockstack-packages/blockstack-gpg | blockstack_gpg/gpg.py | gpg_app_delete_key | def gpg_app_delete_key( blockchain_id, appname, keyname, txid=None, immutable=False, proxy=None, wallet_keys=None, config_dir=None ):
"""
Remove an application GPG key.
Unstash the local private key.
Return {'status': True, ...} on success
Return {'error': ...} on error
If immutable is True, ... | python | def gpg_app_delete_key( blockchain_id, appname, keyname, txid=None, immutable=False, proxy=None, wallet_keys=None, config_dir=None ):
"""
Remove an application GPG key.
Unstash the local private key.
Return {'status': True, ...} on success
Return {'error': ...} on error
If immutable is True, ... | [
"def",
"gpg_app_delete_key",
"(",
"blockchain_id",
",",
"appname",
",",
"keyname",
",",
"txid",
"=",
"None",
",",
"immutable",
"=",
"False",
",",
"proxy",
"=",
"None",
",",
"wallet_keys",
"=",
"None",
",",
"config_dir",
"=",
"None",
")",
":",
"assert",
"... | Remove an application GPG key.
Unstash the local private key.
Return {'status': True, ...} on success
Return {'error': ...} on error
If immutable is True, then remove the data from the user's zonefile, not profile. The delete may take
on the order of an hour to complete on the blockchain. A tra... | [
"Remove",
"an",
"application",
"GPG",
"key",
".",
"Unstash",
"the",
"local",
"private",
"key",
"."
] | e4d51e4e51678d9b946596ca9dec53e2d78c8710 | https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L762-L824 |
41,563 | blockstack-packages/blockstack-gpg | blockstack_gpg/gpg.py | gpg_sign | def gpg_sign( path_to_sign, sender_key_info, config_dir=None, passphrase=None ):
"""
Sign a file on disk.
@sender_key_info should be a dict with
{
'key_id': ...
'key_data': ...
'app_name': ...
}
Return {'status': True, 'sig': ...} on success
Return {'error': ...} on e... | python | def gpg_sign( path_to_sign, sender_key_info, config_dir=None, passphrase=None ):
"""
Sign a file on disk.
@sender_key_info should be a dict with
{
'key_id': ...
'key_data': ...
'app_name': ...
}
Return {'status': True, 'sig': ...} on success
Return {'error': ...} on e... | [
"def",
"gpg_sign",
"(",
"path_to_sign",
",",
"sender_key_info",
",",
"config_dir",
"=",
"None",
",",
"passphrase",
"=",
"None",
")",
":",
"if",
"config_dir",
"is",
"None",
":",
"config_dir",
"=",
"get_config_dir",
"(",
")",
"# ingest keys ",
"tmpdir",
"=",
"... | Sign a file on disk.
@sender_key_info should be a dict with
{
'key_id': ...
'key_data': ...
'app_name': ...
}
Return {'status': True, 'sig': ...} on success
Return {'error': ...} on error | [
"Sign",
"a",
"file",
"on",
"disk",
"."
] | e4d51e4e51678d9b946596ca9dec53e2d78c8710 | https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L905-L950 |
41,564 | blockstack-packages/blockstack-gpg | blockstack_gpg/gpg.py | gpg_verify | def gpg_verify( path_to_verify, sigdata, sender_key_info, config_dir=None ):
"""
Verify a file on disk was signed by the given sender.
@sender_key_info should be a dict with
{
'key_id': ...
'key_data': ...
'app_name'; ...
}
Return {'status': True} on success
Return {'... | python | def gpg_verify( path_to_verify, sigdata, sender_key_info, config_dir=None ):
"""
Verify a file on disk was signed by the given sender.
@sender_key_info should be a dict with
{
'key_id': ...
'key_data': ...
'app_name'; ...
}
Return {'status': True} on success
Return {'... | [
"def",
"gpg_verify",
"(",
"path_to_verify",
",",
"sigdata",
",",
"sender_key_info",
",",
"config_dir",
"=",
"None",
")",
":",
"if",
"config_dir",
"is",
"None",
":",
"config_dir",
"=",
"get_config_dir",
"(",
")",
"# ingest keys ",
"tmpdir",
"=",
"make_gpg_tmphome... | Verify a file on disk was signed by the given sender.
@sender_key_info should be a dict with
{
'key_id': ...
'key_data': ...
'app_name'; ...
}
Return {'status': True} on success
Return {'error': ...} on error | [
"Verify",
"a",
"file",
"on",
"disk",
"was",
"signed",
"by",
"the",
"given",
"sender",
"."
] | e4d51e4e51678d9b946596ca9dec53e2d78c8710 | https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L953-L1001 |
41,565 | blockstack-packages/blockstack-gpg | blockstack_gpg/gpg.py | gpg_encrypt | def gpg_encrypt( fd_in, path_out, sender_key_info, recipient_key_infos, passphrase=None, config_dir=None ):
"""
Encrypt a stream of data for a set of keys.
@sender_key_info should be a dict with
{
'key_id': ...
'key_data': ...
'app_name'; ...
}
Return {'status': True} on ... | python | def gpg_encrypt( fd_in, path_out, sender_key_info, recipient_key_infos, passphrase=None, config_dir=None ):
"""
Encrypt a stream of data for a set of keys.
@sender_key_info should be a dict with
{
'key_id': ...
'key_data': ...
'app_name'; ...
}
Return {'status': True} on ... | [
"def",
"gpg_encrypt",
"(",
"fd_in",
",",
"path_out",
",",
"sender_key_info",
",",
"recipient_key_infos",
",",
"passphrase",
"=",
"None",
",",
"config_dir",
"=",
"None",
")",
":",
"if",
"config_dir",
"is",
"None",
":",
"config_dir",
"=",
"get_config_dir",
"(",
... | Encrypt a stream of data for a set of keys.
@sender_key_info should be a dict with
{
'key_id': ...
'key_data': ...
'app_name'; ...
}
Return {'status': True} on success
Return {'error': ...} on error | [
"Encrypt",
"a",
"stream",
"of",
"data",
"for",
"a",
"set",
"of",
"keys",
"."
] | e4d51e4e51678d9b946596ca9dec53e2d78c8710 | https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L1004-L1054 |
41,566 | blockstack-packages/blockstack-gpg | blockstack_gpg/gpg.py | gpg_decrypt | def gpg_decrypt( fd_in, path_out, sender_key_info, my_key_info, passphrase=None, config_dir=None ):
"""
Decrypt a stream of data using key info
for a private key we own.
@my_key_info and @sender_key_info should be data returned by gpg_app_get_key
{
'key_id': ...
'key_data': ...
... | python | def gpg_decrypt( fd_in, path_out, sender_key_info, my_key_info, passphrase=None, config_dir=None ):
"""
Decrypt a stream of data using key info
for a private key we own.
@my_key_info and @sender_key_info should be data returned by gpg_app_get_key
{
'key_id': ...
'key_data': ...
... | [
"def",
"gpg_decrypt",
"(",
"fd_in",
",",
"path_out",
",",
"sender_key_info",
",",
"my_key_info",
",",
"passphrase",
"=",
"None",
",",
"config_dir",
"=",
"None",
")",
":",
"if",
"config_dir",
"is",
"None",
":",
"config_dir",
"=",
"get_config_dir",
"(",
")",
... | Decrypt a stream of data using key info
for a private key we own.
@my_key_info and @sender_key_info should be data returned by gpg_app_get_key
{
'key_id': ...
'key_data': ...
'app_name': ...
}
Return {'status': True, 'sig': ...} on success
Return {'status': True} on succ... | [
"Decrypt",
"a",
"stream",
"of",
"data",
"using",
"key",
"info",
"for",
"a",
"private",
"key",
"we",
"own",
"."
] | e4d51e4e51678d9b946596ca9dec53e2d78c8710 | https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L1057-L1103 |
41,567 | contains-io/rcli | rcli/usage.py | get_primary_command_usage | def get_primary_command_usage(message=''):
# type: (str) -> str
"""Return the usage string for the primary command."""
if not settings.merge_primary_command and None in settings.subcommands:
return format_usage(settings.subcommands[None].__doc__)
if not message:
message = '\n{}\n'.format... | python | def get_primary_command_usage(message=''):
# type: (str) -> str
"""Return the usage string for the primary command."""
if not settings.merge_primary_command and None in settings.subcommands:
return format_usage(settings.subcommands[None].__doc__)
if not message:
message = '\n{}\n'.format... | [
"def",
"get_primary_command_usage",
"(",
"message",
"=",
"''",
")",
":",
"# type: (str) -> str",
"if",
"not",
"settings",
".",
"merge_primary_command",
"and",
"None",
"in",
"settings",
".",
"subcommands",
":",
"return",
"format_usage",
"(",
"settings",
".",
"subco... | Return the usage string for the primary command. | [
"Return",
"the",
"usage",
"string",
"for",
"the",
"primary",
"command",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/usage.py#L54-L64 |
41,568 | contains-io/rcli | rcli/usage.py | get_help_usage | def get_help_usage(command):
# type: (str) -> None
"""Print out a help message and exit the program.
Args:
command: If a command value is supplied then print the help message for
the command module if available. If the command is '-a' or '--all',
then print the standard help... | python | def get_help_usage(command):
# type: (str) -> None
"""Print out a help message and exit the program.
Args:
command: If a command value is supplied then print the help message for
the command module if available. If the command is '-a' or '--all',
then print the standard help... | [
"def",
"get_help_usage",
"(",
"command",
")",
":",
"# type: (str) -> None",
"if",
"not",
"command",
":",
"doc",
"=",
"get_primary_command_usage",
"(",
")",
"elif",
"command",
"in",
"(",
"'-a'",
",",
"'--all'",
")",
":",
"subcommands",
"=",
"[",
"k",
"for",
... | Print out a help message and exit the program.
Args:
command: If a command value is supplied then print the help message for
the command module if available. If the command is '-a' or '--all',
then print the standard help message but with a full list of
available command... | [
"Print",
"out",
"a",
"help",
"message",
"and",
"exit",
"the",
"program",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/usage.py#L67-L94 |
41,569 | contains-io/rcli | rcli/usage.py | format_usage | def format_usage(doc, width=None):
# type: (str, Optional[int]) -> str
"""Format the docstring for display to the user.
Args:
doc: The docstring to reformat for display.
Returns:
The docstring formatted to parse and display to the user. This includes
dedenting, rewrapping, and ... | python | def format_usage(doc, width=None):
# type: (str, Optional[int]) -> str
"""Format the docstring for display to the user.
Args:
doc: The docstring to reformat for display.
Returns:
The docstring formatted to parse and display to the user. This includes
dedenting, rewrapping, and ... | [
"def",
"format_usage",
"(",
"doc",
",",
"width",
"=",
"None",
")",
":",
"# type: (str, Optional[int]) -> str",
"sections",
"=",
"doc",
".",
"replace",
"(",
"'\\r'",
",",
"''",
")",
".",
"split",
"(",
"'\\n\\n'",
")",
"width",
"=",
"width",
"or",
"get_termi... | Format the docstring for display to the user.
Args:
doc: The docstring to reformat for display.
Returns:
The docstring formatted to parse and display to the user. This includes
dedenting, rewrapping, and translating the docstring if necessary. | [
"Format",
"the",
"docstring",
"for",
"display",
"to",
"the",
"user",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/usage.py#L97-L110 |
41,570 | contains-io/rcli | rcli/usage.py | parse_commands | def parse_commands(docstring):
# type: (str) -> Generator[Tuple[List[str], List[str]], None, None]
"""Parse a docopt-style string for commands and subcommands.
Args:
docstring: A docopt-style string to parse. If the string is not a valid
docopt-style string, it will not yield and values... | python | def parse_commands(docstring):
# type: (str) -> Generator[Tuple[List[str], List[str]], None, None]
"""Parse a docopt-style string for commands and subcommands.
Args:
docstring: A docopt-style string to parse. If the string is not a valid
docopt-style string, it will not yield and values... | [
"def",
"parse_commands",
"(",
"docstring",
")",
":",
"# type: (str) -> Generator[Tuple[List[str], List[str]], None, None]",
"try",
":",
"docopt",
".",
"docopt",
"(",
"docstring",
",",
"argv",
"=",
"(",
")",
")",
"except",
"(",
"TypeError",
",",
"docopt",
".",
"Doc... | Parse a docopt-style string for commands and subcommands.
Args:
docstring: A docopt-style string to parse. If the string is not a valid
docopt-style string, it will not yield and values.
Yields:
All tuples of commands and subcommands found in the docopt docstring. | [
"Parse",
"a",
"docopt",
"-",
"style",
"string",
"for",
"commands",
"and",
"subcommands",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/usage.py#L113-L139 |
41,571 | contains-io/rcli | rcli/usage.py | _merge_doc | def _merge_doc(original, to_merge):
# type: (str, str) -> str
"""Merge two usage strings together.
Args:
original: The source of headers and initial section lines.
to_merge: The source for the additional section lines to append.
Returns:
A new usage string that contains informa... | python | def _merge_doc(original, to_merge):
# type: (str, str) -> str
"""Merge two usage strings together.
Args:
original: The source of headers and initial section lines.
to_merge: The source for the additional section lines to append.
Returns:
A new usage string that contains informa... | [
"def",
"_merge_doc",
"(",
"original",
",",
"to_merge",
")",
":",
"# type: (str, str) -> str",
"if",
"not",
"original",
":",
"return",
"to_merge",
"or",
"''",
"if",
"not",
"to_merge",
":",
"return",
"original",
"or",
"''",
"sections",
"=",
"[",
"]",
"for",
... | Merge two usage strings together.
Args:
original: The source of headers and initial section lines.
to_merge: The source for the additional section lines to append.
Returns:
A new usage string that contains information from both usage strings. | [
"Merge",
"two",
"usage",
"strings",
"together",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/usage.py#L142-L163 |
41,572 | contains-io/rcli | rcli/usage.py | _merge_section | def _merge_section(original, to_merge):
# type: (str, str) -> str
"""Merge two sections together.
Args:
original: The source of header and initial section lines.
to_merge: The source for the additional section lines to append.
Returns:
A new section string that uses the header ... | python | def _merge_section(original, to_merge):
# type: (str, str) -> str
"""Merge two sections together.
Args:
original: The source of header and initial section lines.
to_merge: The source for the additional section lines to append.
Returns:
A new section string that uses the header ... | [
"def",
"_merge_section",
"(",
"original",
",",
"to_merge",
")",
":",
"# type: (str, str) -> str",
"if",
"not",
"original",
":",
"return",
"to_merge",
"or",
"''",
"if",
"not",
"to_merge",
":",
"return",
"original",
"or",
"''",
"try",
":",
"index",
"=",
"origi... | Merge two sections together.
Args:
original: The source of header and initial section lines.
to_merge: The source for the additional section lines to append.
Returns:
A new section string that uses the header of the original argument and
the section lines from both. | [
"Merge",
"two",
"sections",
"together",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/usage.py#L166-L190 |
41,573 | contains-io/rcli | rcli/usage.py | _get_section | def _get_section(name, source):
# type: (str, str) -> Optional[str]
"""Extract the named section from the source.
Args:
name: The name of the section to extract (e.g. "Usage").
source: The usage string to parse.
Returns:
A string containing only the requested section. If the se... | python | def _get_section(name, source):
# type: (str, str) -> Optional[str]
"""Extract the named section from the source.
Args:
name: The name of the section to extract (e.g. "Usage").
source: The usage string to parse.
Returns:
A string containing only the requested section. If the se... | [
"def",
"_get_section",
"(",
"name",
",",
"source",
")",
":",
"# type: (str, str) -> Optional[str]",
"pattern",
"=",
"re",
".",
"compile",
"(",
"'^([^\\n]*{name}[^\\n]*\\n?(?:[ \\t].*?(?:\\n|$))*)'",
".",
"format",
"(",
"name",
"=",
"name",
")",
",",
"re",
".",
"IG... | Extract the named section from the source.
Args:
name: The name of the section to extract (e.g. "Usage").
source: The usage string to parse.
Returns:
A string containing only the requested section. If the section appears
multiple times, each instance will be merged into a singl... | [
"Extract",
"the",
"named",
"section",
"from",
"the",
"source",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/usage.py#L193-L211 |
41,574 | contains-io/rcli | rcli/usage.py | _wrap_section | def _wrap_section(source, width):
# type: (str, int) -> str
"""Wrap the given section string to the current terminal size.
Intelligently wraps the section string to the given width. When wrapping
section lines, it auto-adjusts the spacing between terms and definitions.
It also adjusts commands the ... | python | def _wrap_section(source, width):
# type: (str, int) -> str
"""Wrap the given section string to the current terminal size.
Intelligently wraps the section string to the given width. When wrapping
section lines, it auto-adjusts the spacing between terms and definitions.
It also adjusts commands the ... | [
"def",
"_wrap_section",
"(",
"source",
",",
"width",
")",
":",
"# type: (str, int) -> str",
"if",
"_get_section",
"(",
"'usage'",
",",
"source",
")",
":",
"return",
"_wrap_usage_section",
"(",
"source",
",",
"width",
")",
"if",
"_is_definition_section",
"(",
"so... | Wrap the given section string to the current terminal size.
Intelligently wraps the section string to the given width. When wrapping
section lines, it auto-adjusts the spacing between terms and definitions.
It also adjusts commands the fit the correct length for the arguments.
Args:
source: Th... | [
"Wrap",
"the",
"given",
"section",
"string",
"to",
"the",
"current",
"terminal",
"size",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/usage.py#L214-L235 |
41,575 | contains-io/rcli | rcli/usage.py | _is_definition_section | def _is_definition_section(source):
"""Determine if the source is a definition section.
Args:
source: The usage string source that may be a section.
Returns:
True if the source describes a definition section; otherwise, False.
"""
try:
definitions = textwrap.dedent(source).... | python | def _is_definition_section(source):
"""Determine if the source is a definition section.
Args:
source: The usage string source that may be a section.
Returns:
True if the source describes a definition section; otherwise, False.
"""
try:
definitions = textwrap.dedent(source).... | [
"def",
"_is_definition_section",
"(",
"source",
")",
":",
"try",
":",
"definitions",
"=",
"textwrap",
".",
"dedent",
"(",
"source",
")",
".",
"split",
"(",
"'\\n'",
",",
"1",
")",
"[",
"1",
"]",
".",
"splitlines",
"(",
")",
"return",
"all",
"(",
"re"... | Determine if the source is a definition section.
Args:
source: The usage string source that may be a section.
Returns:
True if the source describes a definition section; otherwise, False. | [
"Determine",
"if",
"the",
"source",
"is",
"a",
"definition",
"section",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/usage.py#L238-L252 |
41,576 | contains-io/rcli | rcli/usage.py | _wrap_usage_section | def _wrap_usage_section(source, width):
# type: (str, int) -> str
"""Wrap the given usage section string to the current terminal size.
Note:
Commands arguments are wrapped to the column that the arguments began
on the first line of the command.
Args:
source: The section string ... | python | def _wrap_usage_section(source, width):
# type: (str, int) -> str
"""Wrap the given usage section string to the current terminal size.
Note:
Commands arguments are wrapped to the column that the arguments began
on the first line of the command.
Args:
source: The section string ... | [
"def",
"_wrap_usage_section",
"(",
"source",
",",
"width",
")",
":",
"# type: (str, int) -> str",
"if",
"not",
"any",
"(",
"len",
"(",
"line",
")",
">",
"width",
"for",
"line",
"in",
"source",
".",
"splitlines",
"(",
")",
")",
":",
"return",
"source",
"s... | Wrap the given usage section string to the current terminal size.
Note:
Commands arguments are wrapped to the column that the arguments began
on the first line of the command.
Args:
source: The section string to wrap.
Returns:
The wrapped section string. | [
"Wrap",
"the",
"given",
"usage",
"section",
"string",
"to",
"the",
"current",
"terminal",
"size",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/usage.py#L255-L280 |
41,577 | contains-io/rcli | rcli/usage.py | _wrap_definition_section | def _wrap_definition_section(source, width):
# type: (str, int) -> str
"""Wrap the given definition section string to the current terminal size.
Note:
Auto-adjusts the spacing between terms and definitions.
Args:
source: The section string to wrap.
Returns:
The wrapped sec... | python | def _wrap_definition_section(source, width):
# type: (str, int) -> str
"""Wrap the given definition section string to the current terminal size.
Note:
Auto-adjusts the spacing between terms and definitions.
Args:
source: The section string to wrap.
Returns:
The wrapped sec... | [
"def",
"_wrap_definition_section",
"(",
"source",
",",
"width",
")",
":",
"# type: (str, int) -> str",
"index",
"=",
"source",
".",
"index",
"(",
"'\\n'",
")",
"+",
"1",
"definitions",
",",
"max_len",
"=",
"_get_definitions",
"(",
"source",
"[",
"index",
":",
... | Wrap the given definition section string to the current terminal size.
Note:
Auto-adjusts the spacing between terms and definitions.
Args:
source: The section string to wrap.
Returns:
The wrapped section string. | [
"Wrap",
"the",
"given",
"definition",
"section",
"string",
"to",
"the",
"current",
"terminal",
"size",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/usage.py#L283-L307 |
41,578 | contains-io/rcli | rcli/usage.py | _get_definitions | def _get_definitions(source):
# type: (str) -> Tuple[Dict[str, str], int]
"""Extract a dictionary of arguments and definitions.
Args:
source: The source for a section of a usage string that contains
definitions.
Returns:
A two-tuple containing a dictionary of all arguments ... | python | def _get_definitions(source):
# type: (str) -> Tuple[Dict[str, str], int]
"""Extract a dictionary of arguments and definitions.
Args:
source: The source for a section of a usage string that contains
definitions.
Returns:
A two-tuple containing a dictionary of all arguments ... | [
"def",
"_get_definitions",
"(",
"source",
")",
":",
"# type: (str) -> Tuple[Dict[str, str], int]",
"max_len",
"=",
"0",
"descs",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"# type: Dict[str, str]",
"lines",
"=",
"(",
"s",
".",
"strip",
"(",
")",
"for",
"s... | Extract a dictionary of arguments and definitions.
Args:
source: The source for a section of a usage string that contains
definitions.
Returns:
A two-tuple containing a dictionary of all arguments and definitions as
well as the length of the longest argument. | [
"Extract",
"a",
"dictionary",
"of",
"arguments",
"and",
"definitions",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/usage.py#L310-L333 |
41,579 | contains-io/rcli | rcli/usage.py | _parse_section | def _parse_section(name, source):
# type: (str, str) -> List[str]
"""Yield each section line.
Note:
Depending on how it is wrapped, a section line can take up more than
one physical line.
Args:
name: The name of the section to extract (e.g. "Usage").
source: The usage s... | python | def _parse_section(name, source):
# type: (str, str) -> List[str]
"""Yield each section line.
Note:
Depending on how it is wrapped, a section line can take up more than
one physical line.
Args:
name: The name of the section to extract (e.g. "Usage").
source: The usage s... | [
"def",
"_parse_section",
"(",
"name",
",",
"source",
")",
":",
"# type: (str, str) -> List[str]",
"section",
"=",
"textwrap",
".",
"dedent",
"(",
"_get_section",
"(",
"name",
",",
"source",
")",
"[",
"7",
":",
"]",
")",
"commands",
"=",
"[",
"]",
"# type: ... | Yield each section line.
Note:
Depending on how it is wrapped, a section line can take up more than
one physical line.
Args:
name: The name of the section to extract (e.g. "Usage").
source: The usage string to parse.
Returns:
A list containing each line, de-wrapped... | [
"Yield",
"each",
"section",
"line",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/usage.py#L336-L361 |
41,580 | asascience-open/paegan-transport | paegan/transport/models/behaviors/lifestage.py | DeadLifeStage.move | def move(self, particle, u, v, w, modelTimestep, **kwargs):
""" I'm dead, so no behaviors should act on me """
# Kill the particle if it isn't settled and isn't already dead.
if not particle.settled and not particle.dead:
particle.die()
# Still save the temperature and sali... | python | def move(self, particle, u, v, w, modelTimestep, **kwargs):
""" I'm dead, so no behaviors should act on me """
# Kill the particle if it isn't settled and isn't already dead.
if not particle.settled and not particle.dead:
particle.die()
# Still save the temperature and sali... | [
"def",
"move",
"(",
"self",
",",
"particle",
",",
"u",
",",
"v",
",",
"w",
",",
"modelTimestep",
",",
"*",
"*",
"kwargs",
")",
":",
"# Kill the particle if it isn't settled and isn't already dead.",
"if",
"not",
"particle",
".",
"settled",
"and",
"not",
"parti... | I'm dead, so no behaviors should act on me | [
"I",
"m",
"dead",
"so",
"no",
"behaviors",
"should",
"act",
"on",
"me"
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/models/behaviors/lifestage.py#L141-L168 |
41,581 | SeattleTestbed/seash | pyreadline/lineeditor/history.py | LineHistory.read_history_file | def read_history_file(self, filename=None):
u'''Load a readline history file.'''
if filename is None:
filename = self.history_filename
try:
for line in open(filename, u'r'):
self.add_history(lineobj.ReadLineTextBuffer(ensure_unicode(line.rstrip())))... | python | def read_history_file(self, filename=None):
u'''Load a readline history file.'''
if filename is None:
filename = self.history_filename
try:
for line in open(filename, u'r'):
self.add_history(lineobj.ReadLineTextBuffer(ensure_unicode(line.rstrip())))... | [
"def",
"read_history_file",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"if",
"filename",
"is",
"None",
":",
"filename",
"=",
"self",
".",
"history_filename",
"try",
":",
"for",
"line",
"in",
"open",
"(",
"filename",
",",
"u'r'",
")",
":",
"se... | u'''Load a readline history file. | [
"u",
"Load",
"a",
"readline",
"history",
"file",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/lineeditor/history.py#L78-L87 |
41,582 | SeattleTestbed/seash | pyreadline/lineeditor/history.py | LineHistory.write_history_file | def write_history_file(self, filename = None):
u'''Save a readline history file.'''
if filename is None:
filename = self.history_filename
fp = open(filename, u'wb')
for line in self.history[-self.history_length:]:
fp.write(ensure_str(line.get_line_text()))
... | python | def write_history_file(self, filename = None):
u'''Save a readline history file.'''
if filename is None:
filename = self.history_filename
fp = open(filename, u'wb')
for line in self.history[-self.history_length:]:
fp.write(ensure_str(line.get_line_text()))
... | [
"def",
"write_history_file",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"if",
"filename",
"is",
"None",
":",
"filename",
"=",
"self",
".",
"history_filename",
"fp",
"=",
"open",
"(",
"filename",
",",
"u'wb'",
")",
"for",
"line",
"in",
"self",
... | u'''Save a readline history file. | [
"u",
"Save",
"a",
"readline",
"history",
"file",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/lineeditor/history.py#L89-L97 |
41,583 | SeattleTestbed/seash | pyreadline/lineeditor/history.py | LineHistory.add_history | def add_history(self, line):
u'''Append a line to the history buffer, as if it was the last line typed.'''
if not hasattr(line, "get_line_text"):
line = lineobj.ReadLineTextBuffer(line)
if not line.get_line_text():
pass
elif len(self.history) > 0 and self.hi... | python | def add_history(self, line):
u'''Append a line to the history buffer, as if it was the last line typed.'''
if not hasattr(line, "get_line_text"):
line = lineobj.ReadLineTextBuffer(line)
if not line.get_line_text():
pass
elif len(self.history) > 0 and self.hi... | [
"def",
"add_history",
"(",
"self",
",",
"line",
")",
":",
"if",
"not",
"hasattr",
"(",
"line",
",",
"\"get_line_text\"",
")",
":",
"line",
"=",
"lineobj",
".",
"ReadLineTextBuffer",
"(",
"line",
")",
"if",
"not",
"line",
".",
"get_line_text",
"(",
")",
... | u'''Append a line to the history buffer, as if it was the last line typed. | [
"u",
"Append",
"a",
"line",
"to",
"the",
"history",
"buffer",
"as",
"if",
"it",
"was",
"the",
"last",
"line",
"typed",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/lineeditor/history.py#L100-L110 |
41,584 | SeattleTestbed/seash | pyreadline/lineeditor/history.py | LineHistory.beginning_of_history | def beginning_of_history(self): # (M-<)
u'''Move to the first line in the history.'''
self.history_cursor = 0
if len(self.history) > 0:
self.l_buffer = self.history[0] | python | def beginning_of_history(self): # (M-<)
u'''Move to the first line in the history.'''
self.history_cursor = 0
if len(self.history) > 0:
self.l_buffer = self.history[0] | [
"def",
"beginning_of_history",
"(",
"self",
")",
":",
"# (M-<)\r",
"self",
".",
"history_cursor",
"=",
"0",
"if",
"len",
"(",
"self",
".",
"history",
")",
">",
"0",
":",
"self",
".",
"l_buffer",
"=",
"self",
".",
"history",
"[",
"0",
"]"
] | u'''Move to the first line in the history. | [
"u",
"Move",
"to",
"the",
"first",
"line",
"in",
"the",
"history",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/lineeditor/history.py#L128-L132 |
41,585 | asascience-open/paegan-transport | paegan/transport/utils/asatransport.py | AsaTransport.get_time_objects_from_model_timesteps | def get_time_objects_from_model_timesteps(cls, times, start):
"""
Calculate the datetimes of the model timesteps
times should start at 0 and be in seconds
"""
modelTimestep = []
newtimes = []
for i in xrange(0, len(times)):
try:
mode... | python | def get_time_objects_from_model_timesteps(cls, times, start):
"""
Calculate the datetimes of the model timesteps
times should start at 0 and be in seconds
"""
modelTimestep = []
newtimes = []
for i in xrange(0, len(times)):
try:
mode... | [
"def",
"get_time_objects_from_model_timesteps",
"(",
"cls",
",",
"times",
",",
"start",
")",
":",
"modelTimestep",
"=",
"[",
"]",
"newtimes",
"=",
"[",
"]",
"for",
"i",
"in",
"xrange",
"(",
"0",
",",
"len",
"(",
"times",
")",
")",
":",
"try",
":",
"m... | Calculate the datetimes of the model timesteps
times should start at 0 and be in seconds | [
"Calculate",
"the",
"datetimes",
"of",
"the",
"model",
"timesteps"
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/utils/asatransport.py#L14-L31 |
41,586 | asascience-open/paegan-transport | paegan/transport/utils/asatransport.py | AsaTransport.fill_polygon_with_points | def fill_polygon_with_points(cls, goal=None, polygon=None):
"""
Fill a shapely polygon with X number of points
"""
if goal is None:
raise ValueError("Must specify the number of points (goal) to fill the polygon with")
if polygon is None or (not isinstance(polygon... | python | def fill_polygon_with_points(cls, goal=None, polygon=None):
"""
Fill a shapely polygon with X number of points
"""
if goal is None:
raise ValueError("Must specify the number of points (goal) to fill the polygon with")
if polygon is None or (not isinstance(polygon... | [
"def",
"fill_polygon_with_points",
"(",
"cls",
",",
"goal",
"=",
"None",
",",
"polygon",
"=",
"None",
")",
":",
"if",
"goal",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Must specify the number of points (goal) to fill the polygon with\"",
")",
"if",
"polygon"... | Fill a shapely polygon with X number of points | [
"Fill",
"a",
"shapely",
"polygon",
"with",
"X",
"number",
"of",
"points"
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/utils/asatransport.py#L34-L60 |
41,587 | asascience-open/paegan-transport | paegan/transport/utils/asatransport.py | AsaTransport.distance_from_location_using_u_v_w | def distance_from_location_using_u_v_w(cls, u=None, v=None, w=None, timestep=None, location=None):
"""
Calculate the greate distance from a location using u, v, and w.
u, v, and w must be in the same units as the timestep. Stick with seconds.
"""
# Move horizontally
... | python | def distance_from_location_using_u_v_w(cls, u=None, v=None, w=None, timestep=None, location=None):
"""
Calculate the greate distance from a location using u, v, and w.
u, v, and w must be in the same units as the timestep. Stick with seconds.
"""
# Move horizontally
... | [
"def",
"distance_from_location_using_u_v_w",
"(",
"cls",
",",
"u",
"=",
"None",
",",
"v",
"=",
"None",
",",
"w",
"=",
"None",
",",
"timestep",
"=",
"None",
",",
"location",
"=",
"None",
")",
":",
"# Move horizontally",
"distance_horiz",
"=",
"0",
"azimuth"... | Calculate the greate distance from a location using u, v, and w.
u, v, and w must be in the same units as the timestep. Stick with seconds. | [
"Calculate",
"the",
"greate",
"distance",
"from",
"a",
"location",
"using",
"u",
"v",
"and",
"w",
"."
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/utils/asatransport.py#L63-L113 |
41,588 | CMUSTRUDEL/strudel.utils | stutils/mapreduce.py | ThreadPool.shutdown | def shutdown(self):
"""Wait for all threads to complete"""
# cleanup
self.started = False
try:
# nice way of doing things - let's wait until all items
# in the queue are processed
for t in self._threads:
t.join()
finally:
... | python | def shutdown(self):
"""Wait for all threads to complete"""
# cleanup
self.started = False
try:
# nice way of doing things - let's wait until all items
# in the queue are processed
for t in self._threads:
t.join()
finally:
... | [
"def",
"shutdown",
"(",
"self",
")",
":",
"# cleanup",
"self",
".",
"started",
"=",
"False",
"try",
":",
"# nice way of doing things - let's wait until all items",
"# in the queue are processed",
"for",
"t",
"in",
"self",
".",
"_threads",
":",
"t",
".",
"join",
"(... | Wait for all threads to complete | [
"Wait",
"for",
"all",
"threads",
"to",
"complete"
] | 888ef72fcdb851b5873092bc9c4d6958733691f2 | https://github.com/CMUSTRUDEL/strudel.utils/blob/888ef72fcdb851b5873092bc9c4d6958733691f2/stutils/mapreduce.py#L119-L131 |
41,589 | tr00st/insult_generator | insultgenerator/phrases.py | _unpack_bytes | def _unpack_bytes(bytes):
"""
Unpack a set of bytes into an integer. First pads to 4 bytes.
Little endian.
"""
if bytes == b'':
return 0
int_length = 4
len_diff = int_length - len(bytes)
bytes = bytes + len_diff * b'\x00'
return struct.unpack("<L", bytes)[0] | python | def _unpack_bytes(bytes):
"""
Unpack a set of bytes into an integer. First pads to 4 bytes.
Little endian.
"""
if bytes == b'':
return 0
int_length = 4
len_diff = int_length - len(bytes)
bytes = bytes + len_diff * b'\x00'
return struct.unpack("<L", bytes)[0] | [
"def",
"_unpack_bytes",
"(",
"bytes",
")",
":",
"if",
"bytes",
"==",
"b''",
":",
"return",
"0",
"int_length",
"=",
"4",
"len_diff",
"=",
"int_length",
"-",
"len",
"(",
"bytes",
")",
"bytes",
"=",
"bytes",
"+",
"len_diff",
"*",
"b'\\x00'",
"return",
"st... | Unpack a set of bytes into an integer. First pads to 4 bytes.
Little endian. | [
"Unpack",
"a",
"set",
"of",
"bytes",
"into",
"an",
"integer",
".",
"First",
"pads",
"to",
"4",
"bytes",
".",
"Little",
"endian",
"."
] | a4496b29ea4beae6b82a4119e8dfbd871be75dbb | https://github.com/tr00st/insult_generator/blob/a4496b29ea4beae6b82a4119e8dfbd871be75dbb/insultgenerator/phrases.py#L4-L14 |
41,590 | bitlabstudio/django-rapid-prototyping | rapid_prototyping/context/utils.py | get_sprints | def get_sprints():
"""
Returns all sprints, enriched with their assigned tasks.
The project should only have one ``sprints.py`` module. We will define it's
path via the ``RAPID_PROTOTYPING_SPRINTS_MODULE`` setting. The setting
should be the fully qualified name of the ``sprints.py`` module (i.e.
... | python | def get_sprints():
"""
Returns all sprints, enriched with their assigned tasks.
The project should only have one ``sprints.py`` module. We will define it's
path via the ``RAPID_PROTOTYPING_SPRINTS_MODULE`` setting. The setting
should be the fully qualified name of the ``sprints.py`` module (i.e.
... | [
"def",
"get_sprints",
"(",
")",
":",
"sprints",
"=",
"load_member_from_setting",
"(",
"'RAPID_PROTOTYPING_SPRINTS_MODULE'",
")",
"all_tasks",
"=",
"[",
"]",
"# TODO The onerror parameter is basically a workaround to ignore errors",
"# The reason for that being, that in my case, the G... | Returns all sprints, enriched with their assigned tasks.
The project should only have one ``sprints.py`` module. We will define it's
path via the ``RAPID_PROTOTYPING_SPRINTS_MODULE`` setting. The setting
should be the fully qualified name of the ``sprints.py`` module (i.e.
``projectname.context.sprints... | [
"Returns",
"all",
"sprints",
"enriched",
"with",
"their",
"assigned",
"tasks",
"."
] | fd14ab5453bd7a0c2d5b973e8d96148963b03ab0 | https://github.com/bitlabstudio/django-rapid-prototyping/blob/fd14ab5453bd7a0c2d5b973e8d96148963b03ab0/rapid_prototyping/context/utils.py#L10-L58 |
41,591 | bitlabstudio/django-rapid-prototyping | rapid_prototyping/context/utils.py | append_overhead_costs | def append_overhead_costs(costs, new_id, overhead_percentage=0.15):
"""
Adds 15% overhead costs to the list of costs.
Usage::
from rapid_prototyping.context.utils import append_overhead_costs
costs = [
....
]
costs = append_overhead_costs(costs, MAIN_ID + get_co... | python | def append_overhead_costs(costs, new_id, overhead_percentage=0.15):
"""
Adds 15% overhead costs to the list of costs.
Usage::
from rapid_prototyping.context.utils import append_overhead_costs
costs = [
....
]
costs = append_overhead_costs(costs, MAIN_ID + get_co... | [
"def",
"append_overhead_costs",
"(",
"costs",
",",
"new_id",
",",
"overhead_percentage",
"=",
"0.15",
")",
":",
"total_time",
"=",
"0",
"for",
"item",
"in",
"costs",
":",
"total_time",
"+=",
"item",
"[",
"'time'",
"]",
"costs",
".",
"append",
"(",
"{",
"... | Adds 15% overhead costs to the list of costs.
Usage::
from rapid_prototyping.context.utils import append_overhead_costs
costs = [
....
]
costs = append_overhead_costs(costs, MAIN_ID + get_counter(counter)[0])
:param costs: Your final list of costs.
:param new_i... | [
"Adds",
"15%",
"overhead",
"costs",
"to",
"the",
"list",
"of",
"costs",
"."
] | fd14ab5453bd7a0c2d5b973e8d96148963b03ab0 | https://github.com/bitlabstudio/django-rapid-prototyping/blob/fd14ab5453bd7a0c2d5b973e8d96148963b03ab0/rapid_prototyping/context/utils.py#L84-L109 |
41,592 | ponty/confduino | confduino/__init__.py | arduino_default_path | def arduino_default_path():
"""platform specific default root path."""
if sys.platform == 'darwin':
s = path('/Applications/Arduino.app/Contents/Resources/Java')
elif sys.platform == 'win32':
s = None
else:
s = path('/usr/share/arduino/')
return s | python | def arduino_default_path():
"""platform specific default root path."""
if sys.platform == 'darwin':
s = path('/Applications/Arduino.app/Contents/Resources/Java')
elif sys.platform == 'win32':
s = None
else:
s = path('/usr/share/arduino/')
return s | [
"def",
"arduino_default_path",
"(",
")",
":",
"if",
"sys",
".",
"platform",
"==",
"'darwin'",
":",
"s",
"=",
"path",
"(",
"'/Applications/Arduino.app/Contents/Resources/Java'",
")",
"elif",
"sys",
".",
"platform",
"==",
"'win32'",
":",
"s",
"=",
"None",
"else"... | platform specific default root path. | [
"platform",
"specific",
"default",
"root",
"path",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/__init__.py#L16-L24 |
41,593 | agrc/agrc.python | agrc/update.py | checkForChanges | def checkForChanges(f, sde, isTable):
"""
returns False if there are no changes
"""
# try simple feature count first
fCount = int(arcpy.GetCount_management(f).getOutput(0))
sdeCount = int(arcpy.GetCount_management(sde).getOutput(0))
if fCount != sdeCount:
return True
fields = [... | python | def checkForChanges(f, sde, isTable):
"""
returns False if there are no changes
"""
# try simple feature count first
fCount = int(arcpy.GetCount_management(f).getOutput(0))
sdeCount = int(arcpy.GetCount_management(sde).getOutput(0))
if fCount != sdeCount:
return True
fields = [... | [
"def",
"checkForChanges",
"(",
"f",
",",
"sde",
",",
"isTable",
")",
":",
"# try simple feature count first",
"fCount",
"=",
"int",
"(",
"arcpy",
".",
"GetCount_management",
"(",
"f",
")",
".",
"getOutput",
"(",
"0",
")",
")",
"sdeCount",
"=",
"int",
"(",
... | returns False if there are no changes | [
"returns",
"False",
"if",
"there",
"are",
"no",
"changes"
] | be427e919bd4cdd6f19524b7f7fe18882429c25b | https://github.com/agrc/agrc.python/blob/be427e919bd4cdd6f19524b7f7fe18882429c25b/agrc/update.py#L164-L248 |
41,594 | ponty/confduino | confduino/examples/metaboard.py | install_metaboard | def install_metaboard(
replace_existing=False,
):
"""install metaboard.
http://metalab.at/wiki/Metaboard
"""
metaboard = AutoBunch()
metaboard.name = 'Metaboard'
metaboard.upload.protocol = 'usbasp'
metaboard.upload.maximum_size = '14336'
metaboard.upload.speed = '19200'
meta... | python | def install_metaboard(
replace_existing=False,
):
"""install metaboard.
http://metalab.at/wiki/Metaboard
"""
metaboard = AutoBunch()
metaboard.name = 'Metaboard'
metaboard.upload.protocol = 'usbasp'
metaboard.upload.maximum_size = '14336'
metaboard.upload.speed = '19200'
meta... | [
"def",
"install_metaboard",
"(",
"replace_existing",
"=",
"False",
",",
")",
":",
"metaboard",
"=",
"AutoBunch",
"(",
")",
"metaboard",
".",
"name",
"=",
"'Metaboard'",
"metaboard",
".",
"upload",
".",
"protocol",
"=",
"'usbasp'",
"metaboard",
".",
"upload",
... | install metaboard.
http://metalab.at/wiki/Metaboard | [
"install",
"metaboard",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/examples/metaboard.py#L7-L30 |
41,595 | AtomHash/evernode | evernode/classes/paginate.py | Paginate.__total_pages | def __total_pages(self) -> int:
""" Return max pages created by limit """
row_count = self.model.query.count()
if isinstance(row_count, int):
return int(row_count / self.limit)
return None | python | def __total_pages(self) -> int:
""" Return max pages created by limit """
row_count = self.model.query.count()
if isinstance(row_count, int):
return int(row_count / self.limit)
return None | [
"def",
"__total_pages",
"(",
"self",
")",
"->",
"int",
":",
"row_count",
"=",
"self",
".",
"model",
".",
"query",
".",
"count",
"(",
")",
"if",
"isinstance",
"(",
"row_count",
",",
"int",
")",
":",
"return",
"int",
"(",
"row_count",
"/",
"self",
".",... | Return max pages created by limit | [
"Return",
"max",
"pages",
"created",
"by",
"limit"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/paginate.py#L22-L27 |
41,596 | AtomHash/evernode | evernode/classes/paginate.py | Paginate.links | def links(self, base_link, current_page) -> dict:
""" Return JSON paginate links """
max_pages = self.max_pages - 1 if \
self.max_pages > 0 else self.max_pages
base_link = '/%s' % (base_link.strip("/"))
self_page = current_page
prev = current_page - 1 if current... | python | def links(self, base_link, current_page) -> dict:
""" Return JSON paginate links """
max_pages = self.max_pages - 1 if \
self.max_pages > 0 else self.max_pages
base_link = '/%s' % (base_link.strip("/"))
self_page = current_page
prev = current_page - 1 if current... | [
"def",
"links",
"(",
"self",
",",
"base_link",
",",
"current_page",
")",
"->",
"dict",
":",
"max_pages",
"=",
"self",
".",
"max_pages",
"-",
"1",
"if",
"self",
".",
"max_pages",
">",
"0",
"else",
"self",
".",
"max_pages",
"base_link",
"=",
"'/%s'",
"%"... | Return JSON paginate links | [
"Return",
"JSON",
"paginate",
"links"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/paginate.py#L83-L103 |
41,597 | AtomHash/evernode | evernode/classes/paginate.py | Paginate.json_paginate | def json_paginate(self, base_url, page_number):
""" Return a dict for a JSON paginate """
data = self.page(page_number)
first_id = None
last_id = None
if data:
first_id = data[0].id
last_id = data[-1].id
return {
'meta': {
... | python | def json_paginate(self, base_url, page_number):
""" Return a dict for a JSON paginate """
data = self.page(page_number)
first_id = None
last_id = None
if data:
first_id = data[0].id
last_id = data[-1].id
return {
'meta': {
... | [
"def",
"json_paginate",
"(",
"self",
",",
"base_url",
",",
"page_number",
")",
":",
"data",
"=",
"self",
".",
"page",
"(",
"page_number",
")",
"first_id",
"=",
"None",
"last_id",
"=",
"None",
"if",
"data",
":",
"first_id",
"=",
"data",
"[",
"0",
"]",
... | Return a dict for a JSON paginate | [
"Return",
"a",
"dict",
"for",
"a",
"JSON",
"paginate"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/paginate.py#L105-L122 |
41,598 | jaraco/jaraco.logging | jaraco/logging.py | add_arguments | def add_arguments(parser, default_level=logging.INFO):
"""
Add arguments to an ArgumentParser or OptionParser for purposes of
grabbing a logging level.
"""
adder = (
getattr(parser, 'add_argument', None)
or getattr(parser, 'add_option')
)
adder(
'-l', '--log-level', default=default_level, type=lo... | python | def add_arguments(parser, default_level=logging.INFO):
"""
Add arguments to an ArgumentParser or OptionParser for purposes of
grabbing a logging level.
"""
adder = (
getattr(parser, 'add_argument', None)
or getattr(parser, 'add_option')
)
adder(
'-l', '--log-level', default=default_level, type=lo... | [
"def",
"add_arguments",
"(",
"parser",
",",
"default_level",
"=",
"logging",
".",
"INFO",
")",
":",
"adder",
"=",
"(",
"getattr",
"(",
"parser",
",",
"'add_argument'",
",",
"None",
")",
"or",
"getattr",
"(",
"parser",
",",
"'add_option'",
")",
")",
"adde... | Add arguments to an ArgumentParser or OptionParser for purposes of
grabbing a logging level. | [
"Add",
"arguments",
"to",
"an",
"ArgumentParser",
"or",
"OptionParser",
"for",
"purposes",
"of",
"grabbing",
"a",
"logging",
"level",
"."
] | 202d0d3b7c16503f9b8de83b6054f1306ae61930 | https://github.com/jaraco/jaraco.logging/blob/202d0d3b7c16503f9b8de83b6054f1306ae61930/jaraco/logging.py#L28-L39 |
41,599 | jaraco/jaraco.logging | jaraco/logging.py | setup | def setup(options, **kwargs):
"""
Setup logging with options or arguments from an OptionParser or
ArgumentParser. Also pass any keyword arguments to the basicConfig
call.
"""
params = dict(kwargs)
params.update(level=options.log_level)
logging.basicConfig(**params) | python | def setup(options, **kwargs):
"""
Setup logging with options or arguments from an OptionParser or
ArgumentParser. Also pass any keyword arguments to the basicConfig
call.
"""
params = dict(kwargs)
params.update(level=options.log_level)
logging.basicConfig(**params) | [
"def",
"setup",
"(",
"options",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"dict",
"(",
"kwargs",
")",
"params",
".",
"update",
"(",
"level",
"=",
"options",
".",
"log_level",
")",
"logging",
".",
"basicConfig",
"(",
"*",
"*",
"params",
")"
] | Setup logging with options or arguments from an OptionParser or
ArgumentParser. Also pass any keyword arguments to the basicConfig
call. | [
"Setup",
"logging",
"with",
"options",
"or",
"arguments",
"from",
"an",
"OptionParser",
"or",
"ArgumentParser",
".",
"Also",
"pass",
"any",
"keyword",
"arguments",
"to",
"the",
"basicConfig",
"call",
"."
] | 202d0d3b7c16503f9b8de83b6054f1306ae61930 | https://github.com/jaraco/jaraco.logging/blob/202d0d3b7c16503f9b8de83b6054f1306ae61930/jaraco/logging.py#L42-L50 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.