repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | check_lazy_load_gemeente | def check_lazy_load_gemeente(f):
'''
Decorator function to lazy load a :class:`Gemeente`.
'''
def wrapper(self):
gemeente = self
if (getattr(gemeente, '_%s' % f.__name__, None) is None):
log.debug('Lazy loading Gemeente %d', gemeente.id)
gemeente.check_gateway()
... | python | def check_lazy_load_gemeente(f):
'''
Decorator function to lazy load a :class:`Gemeente`.
'''
def wrapper(self):
gemeente = self
if (getattr(gemeente, '_%s' % f.__name__, None) is None):
log.debug('Lazy loading Gemeente %d', gemeente.id)
gemeente.check_gateway()
... | [
"def",
"check_lazy_load_gemeente",
"(",
"f",
")",
":",
"def",
"wrapper",
"(",
"self",
")",
":",
"gemeente",
"=",
"self",
"if",
"(",
"getattr",
"(",
"gemeente",
",",
"'_%s'",
"%",
"f",
".",
"__name__",
",",
"None",
")",
"is",
"None",
")",
":",
"log",
... | Decorator function to lazy load a :class:`Gemeente`. | [
"Decorator",
"function",
"to",
"lazy",
"load",
"a",
":",
"class",
":",
"Gemeente",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L548-L564 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | check_lazy_load_afdeling | def check_lazy_load_afdeling(f):
'''
Decorator function to lazy load a :class:`Afdeling`.
'''
def wrapper(self):
afdeling = self
if (getattr(afdeling, '_%s' % f.__name__, None) is None):
log.debug('Lazy loading Afdeling %d', afdeling.id)
afdeling.check_gateway()
... | python | def check_lazy_load_afdeling(f):
'''
Decorator function to lazy load a :class:`Afdeling`.
'''
def wrapper(self):
afdeling = self
if (getattr(afdeling, '_%s' % f.__name__, None) is None):
log.debug('Lazy loading Afdeling %d', afdeling.id)
afdeling.check_gateway()
... | [
"def",
"check_lazy_load_afdeling",
"(",
"f",
")",
":",
"def",
"wrapper",
"(",
"self",
")",
":",
"afdeling",
"=",
"self",
"if",
"(",
"getattr",
"(",
"afdeling",
",",
"'_%s'",
"%",
"f",
".",
"__name__",
",",
"None",
")",
"is",
"None",
")",
":",
"log",
... | Decorator function to lazy load a :class:`Afdeling`. | [
"Decorator",
"function",
"to",
"lazy",
"load",
"a",
":",
"class",
":",
"Afdeling",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L611-L628 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | check_lazy_load_sectie | def check_lazy_load_sectie(f):
'''
Decorator function to lazy load a :class:`Sectie`.
'''
def wrapper(self):
sectie = self
if (getattr(sectie, '_%s' % f.__name__, None) is None):
log.debug('Lazy loading Sectie %s in Afdeling %d', sectie.id, sectie.afdeling.id)
se... | python | def check_lazy_load_sectie(f):
'''
Decorator function to lazy load a :class:`Sectie`.
'''
def wrapper(self):
sectie = self
if (getattr(sectie, '_%s' % f.__name__, None) is None):
log.debug('Lazy loading Sectie %s in Afdeling %d', sectie.id, sectie.afdeling.id)
se... | [
"def",
"check_lazy_load_sectie",
"(",
"f",
")",
":",
"def",
"wrapper",
"(",
"self",
")",
":",
"sectie",
"=",
"self",
"if",
"(",
"getattr",
"(",
"sectie",
",",
"'_%s'",
"%",
"f",
".",
"__name__",
",",
"None",
")",
"is",
"None",
")",
":",
"log",
".",... | Decorator function to lazy load a :class:`Sectie`. | [
"Decorator",
"function",
"to",
"lazy",
"load",
"a",
":",
"class",
":",
"Sectie",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L703-L720 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | check_lazy_load_perceel | def check_lazy_load_perceel(f):
'''
Decorator function to lazy load a :class:`Perceel`.
'''
def wrapper(self):
perceel = self
if (getattr(perceel, '_%s' % f.__name__, None) is None):
log.debug(
'Lazy loading Perceel %s in Sectie %s in Afdeling %d',
... | python | def check_lazy_load_perceel(f):
'''
Decorator function to lazy load a :class:`Perceel`.
'''
def wrapper(self):
perceel = self
if (getattr(perceel, '_%s' % f.__name__, None) is None):
log.debug(
'Lazy loading Perceel %s in Sectie %s in Afdeling %d',
... | [
"def",
"check_lazy_load_perceel",
"(",
"f",
")",
":",
"def",
"wrapper",
"(",
"self",
")",
":",
"perceel",
"=",
"self",
"if",
"(",
"getattr",
"(",
"perceel",
",",
"'_%s'",
"%",
"f",
".",
"__name__",
",",
"None",
")",
"is",
"None",
")",
":",
"log",
"... | Decorator function to lazy load a :class:`Perceel`. | [
"Decorator",
"function",
"to",
"lazy",
"load",
"a",
":",
"class",
":",
"Perceel",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L776-L801 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | CapakeyRestGateway._parse_bounding_box | def _parse_bounding_box(bounding_box):
'''
Parse response bounding box from the CapakeyRestGateway to (MinimumX, MinimumY, MaximumX, MaximumY)
:param bounding_box: response bounding box from the CapakeyRestGateway
:return: (MinimumX, MinimumY, MaximumX, MaximumY)
'''
... | python | def _parse_bounding_box(bounding_box):
'''
Parse response bounding box from the CapakeyRestGateway to (MinimumX, MinimumY, MaximumX, MaximumY)
:param bounding_box: response bounding box from the CapakeyRestGateway
:return: (MinimumX, MinimumY, MaximumX, MaximumY)
'''
... | [
"def",
"_parse_bounding_box",
"(",
"bounding_box",
")",
":",
"coordinates",
"=",
"json",
".",
"loads",
"(",
"bounding_box",
")",
"[",
"\"coordinates\"",
"]",
"x_coords",
"=",
"[",
"x",
"for",
"x",
",",
"y",
"in",
"coordinates",
"[",
"0",
"]",
"]",
"y_coo... | Parse response bounding box from the CapakeyRestGateway to (MinimumX, MinimumY, MaximumX, MaximumY)
:param bounding_box: response bounding box from the CapakeyRestGateway
:return: (MinimumX, MinimumY, MaximumX, MaximumY) | [
"Parse",
"response",
"bounding",
"box",
"from",
"the",
"CapakeyRestGateway",
"to",
"(",
"MinimumX",
"MinimumY",
"MaximumX",
"MaximumY",
")",
":",
"param",
"bounding_box",
":",
"response",
"bounding",
"box",
"from",
"the",
"CapakeyRestGateway",
":",
"return",
":",
... | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L94-L104 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | CapakeyRestGateway.list_gemeenten | def list_gemeenten(self, sort=1):
'''
List all `gemeenten` in Vlaanderen.
:param integer sort: What field to sort on.
:rtype: A :class:`list` of :class:`Gemeente`.
'''
def creator():
url = self.base_url + '/municipality'
h = self.base_headers
... | python | def list_gemeenten(self, sort=1):
'''
List all `gemeenten` in Vlaanderen.
:param integer sort: What field to sort on.
:rtype: A :class:`list` of :class:`Gemeente`.
'''
def creator():
url = self.base_url + '/municipality'
h = self.base_headers
... | [
"def",
"list_gemeenten",
"(",
"self",
",",
"sort",
"=",
"1",
")",
":",
"def",
"creator",
"(",
")",
":",
"url",
"=",
"self",
".",
"base_url",
"+",
"'/municipality'",
"h",
"=",
"self",
".",
"base_headers",
"p",
"=",
"{",
"'orderbyCode'",
":",
"sort",
"... | List all `gemeenten` in Vlaanderen.
:param integer sort: What field to sort on.
:rtype: A :class:`list` of :class:`Gemeente`. | [
"List",
"all",
"gemeenten",
"in",
"Vlaanderen",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L106-L133 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | CapakeyRestGateway.get_gemeente_by_id | def get_gemeente_by_id(self, id):
'''
Retrieve a `gemeente` by id (the NIScode).
:rtype: :class:`Gemeente`
'''
def creator():
url = self.base_url + '/municipality/%s' % id
h = self.base_headers
p = {
'geometry': 'full',
... | python | def get_gemeente_by_id(self, id):
'''
Retrieve a `gemeente` by id (the NIScode).
:rtype: :class:`Gemeente`
'''
def creator():
url = self.base_url + '/municipality/%s' % id
h = self.base_headers
p = {
'geometry': 'full',
... | [
"def",
"get_gemeente_by_id",
"(",
"self",
",",
"id",
")",
":",
"def",
"creator",
"(",
")",
":",
"url",
"=",
"self",
".",
"base_url",
"+",
"'/municipality/%s'",
"%",
"id",
"h",
"=",
"self",
".",
"base_headers",
"p",
"=",
"{",
"'geometry'",
":",
"'full'"... | Retrieve a `gemeente` by id (the NIScode).
:rtype: :class:`Gemeente` | [
"Retrieve",
"a",
"gemeente",
"by",
"id",
"(",
"the",
"NIScode",
")",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L135-L164 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | CapakeyRestGateway.list_kadastrale_afdelingen | def list_kadastrale_afdelingen(self):
'''
List all `kadastrale afdelingen` in Flanders.
:param integer sort: Field to sort on.
:rtype: A :class:`list` of :class:`Afdeling`.
'''
def creator():
gemeentes = self.list_gemeenten()
res = []
... | python | def list_kadastrale_afdelingen(self):
'''
List all `kadastrale afdelingen` in Flanders.
:param integer sort: Field to sort on.
:rtype: A :class:`list` of :class:`Afdeling`.
'''
def creator():
gemeentes = self.list_gemeenten()
res = []
... | [
"def",
"list_kadastrale_afdelingen",
"(",
"self",
")",
":",
"def",
"creator",
"(",
")",
":",
"gemeentes",
"=",
"self",
".",
"list_gemeenten",
"(",
")",
"res",
"=",
"[",
"]",
"for",
"g",
"in",
"gemeentes",
":",
"res",
"+=",
"self",
".",
"list_kadastrale_a... | List all `kadastrale afdelingen` in Flanders.
:param integer sort: Field to sort on.
:rtype: A :class:`list` of :class:`Afdeling`. | [
"List",
"all",
"kadastrale",
"afdelingen",
"in",
"Flanders",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L166-L186 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | CapakeyRestGateway.list_kadastrale_afdelingen_by_gemeente | def list_kadastrale_afdelingen_by_gemeente(self, gemeente, sort=1):
'''
List all `kadastrale afdelingen` in a `gemeente`.
:param gemeente: The :class:`Gemeente` for which the \
`afdelingen` are wanted.
:param integer sort: Field to sort on.
:rtype: A :class:`list` of... | python | def list_kadastrale_afdelingen_by_gemeente(self, gemeente, sort=1):
'''
List all `kadastrale afdelingen` in a `gemeente`.
:param gemeente: The :class:`Gemeente` for which the \
`afdelingen` are wanted.
:param integer sort: Field to sort on.
:rtype: A :class:`list` of... | [
"def",
"list_kadastrale_afdelingen_by_gemeente",
"(",
"self",
",",
"gemeente",
",",
"sort",
"=",
"1",
")",
":",
"try",
":",
"gid",
"=",
"gemeente",
".",
"id",
"except",
"AttributeError",
":",
"gid",
"=",
"gemeente",
"gemeente",
"=",
"self",
".",
"get_gemeent... | List all `kadastrale afdelingen` in a `gemeente`.
:param gemeente: The :class:`Gemeente` for which the \
`afdelingen` are wanted.
:param integer sort: Field to sort on.
:rtype: A :class:`list` of :class:`Afdeling`. | [
"List",
"all",
"kadastrale",
"afdelingen",
"in",
"a",
"gemeente",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L188-L225 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | CapakeyRestGateway.get_kadastrale_afdeling_by_id | def get_kadastrale_afdeling_by_id(self, aid):
'''
Retrieve a 'kadastrale afdeling' by id.
:param aid: An id of a `kadastrale afdeling`.
:rtype: A :class:`Afdeling`.
'''
def creator():
url = self.base_url + '/department/%s' % (aid)
h = self.base_h... | python | def get_kadastrale_afdeling_by_id(self, aid):
'''
Retrieve a 'kadastrale afdeling' by id.
:param aid: An id of a `kadastrale afdeling`.
:rtype: A :class:`Afdeling`.
'''
def creator():
url = self.base_url + '/department/%s' % (aid)
h = self.base_h... | [
"def",
"get_kadastrale_afdeling_by_id",
"(",
"self",
",",
"aid",
")",
":",
"def",
"creator",
"(",
")",
":",
"url",
"=",
"self",
".",
"base_url",
"+",
"'/department/%s'",
"%",
"(",
"aid",
")",
"h",
"=",
"self",
".",
"base_headers",
"p",
"=",
"{",
"'geom... | Retrieve a 'kadastrale afdeling' by id.
:param aid: An id of a `kadastrale afdeling`.
:rtype: A :class:`Afdeling`. | [
"Retrieve",
"a",
"kadastrale",
"afdeling",
"by",
"id",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L227-L258 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | CapakeyRestGateway.list_secties_by_afdeling | def list_secties_by_afdeling(self, afdeling):
'''
List all `secties` in a `kadastrale afdeling`.
:param afdeling: The :class:`Afdeling` for which the `secties` are \
wanted. Can also be the id of and `afdeling`.
:rtype: A :class:`list` of `Sectie`.
'''
try:
... | python | def list_secties_by_afdeling(self, afdeling):
'''
List all `secties` in a `kadastrale afdeling`.
:param afdeling: The :class:`Afdeling` for which the `secties` are \
wanted. Can also be the id of and `afdeling`.
:rtype: A :class:`list` of `Sectie`.
'''
try:
... | [
"def",
"list_secties_by_afdeling",
"(",
"self",
",",
"afdeling",
")",
":",
"try",
":",
"aid",
"=",
"afdeling",
".",
"id",
"gid",
"=",
"afdeling",
".",
"gemeente",
".",
"id",
"except",
"AttributeError",
":",
"aid",
"=",
"afdeling",
"afdeling",
"=",
"self",
... | List all `secties` in a `kadastrale afdeling`.
:param afdeling: The :class:`Afdeling` for which the `secties` are \
wanted. Can also be the id of and `afdeling`.
:rtype: A :class:`list` of `Sectie`. | [
"List",
"all",
"secties",
"in",
"a",
"kadastrale",
"afdeling",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L260-L295 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | CapakeyRestGateway.get_sectie_by_id_and_afdeling | def get_sectie_by_id_and_afdeling(self, id, afdeling):
'''
Get a `sectie`.
:param id: An id of a sectie. eg. "A"
:param afdeling: The :class:`Afdeling` for in which the `sectie` can \
be found. Can also be the id of and `afdeling`.
:rtype: A :class:`Sectie`.
... | python | def get_sectie_by_id_and_afdeling(self, id, afdeling):
'''
Get a `sectie`.
:param id: An id of a sectie. eg. "A"
:param afdeling: The :class:`Afdeling` for in which the `sectie` can \
be found. Can also be the id of and `afdeling`.
:rtype: A :class:`Sectie`.
... | [
"def",
"get_sectie_by_id_and_afdeling",
"(",
"self",
",",
"id",
",",
"afdeling",
")",
":",
"try",
":",
"aid",
"=",
"afdeling",
".",
"id",
"except",
"AttributeError",
":",
"aid",
"=",
"afdeling",
"afdeling",
"=",
"self",
".",
"get_kadastrale_afdeling_by_id",
"(... | Get a `sectie`.
:param id: An id of a sectie. eg. "A"
:param afdeling: The :class:`Afdeling` for in which the `sectie` can \
be found. Can also be the id of and `afdeling`.
:rtype: A :class:`Sectie`. | [
"Get",
"a",
"sectie",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L297-L335 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | CapakeyRestGateway.list_percelen_by_sectie | def list_percelen_by_sectie(self, sectie):
'''
List all percelen in a `sectie`.
:param sectie: The :class:`Sectie` for which the percelen are wanted.
:param integer sort: Field to sort on.
:rtype: A :class:`list` of :class:`Perceel`.
'''
sid = sectie.id
a... | python | def list_percelen_by_sectie(self, sectie):
'''
List all percelen in a `sectie`.
:param sectie: The :class:`Sectie` for which the percelen are wanted.
:param integer sort: Field to sort on.
:rtype: A :class:`list` of :class:`Perceel`.
'''
sid = sectie.id
a... | [
"def",
"list_percelen_by_sectie",
"(",
"self",
",",
"sectie",
")",
":",
"sid",
"=",
"sectie",
".",
"id",
"aid",
"=",
"sectie",
".",
"afdeling",
".",
"id",
"gid",
"=",
"sectie",
".",
"afdeling",
".",
"gemeente",
".",
"id",
"sectie",
".",
"clear_gateway",
... | List all percelen in a `sectie`.
:param sectie: The :class:`Sectie` for which the percelen are wanted.
:param integer sort: Field to sort on.
:rtype: A :class:`list` of :class:`Perceel`. | [
"List",
"all",
"percelen",
"in",
"a",
"sectie",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L369-L405 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | CapakeyRestGateway.get_perceel_by_id_and_sectie | def get_perceel_by_id_and_sectie(self, id, sectie):
'''
Get a `perceel`.
:param id: An id for a `perceel`.
:param sectie: The :class:`Sectie` that contains the perceel.
:rtype: :class:`Perceel`
'''
sid = sectie.id
aid = sectie.afdeling.id
gid = se... | python | def get_perceel_by_id_and_sectie(self, id, sectie):
'''
Get a `perceel`.
:param id: An id for a `perceel`.
:param sectie: The :class:`Sectie` that contains the perceel.
:rtype: :class:`Perceel`
'''
sid = sectie.id
aid = sectie.afdeling.id
gid = se... | [
"def",
"get_perceel_by_id_and_sectie",
"(",
"self",
",",
"id",
",",
"sectie",
")",
":",
"sid",
"=",
"sectie",
".",
"id",
"aid",
"=",
"sectie",
".",
"afdeling",
".",
"id",
"gid",
"=",
"sectie",
".",
"afdeling",
".",
"gemeente",
".",
"id",
"sectie",
".",... | Get a `perceel`.
:param id: An id for a `perceel`.
:param sectie: The :class:`Sectie` that contains the perceel.
:rtype: :class:`Perceel` | [
"Get",
"a",
"perceel",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L407-L448 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | CapakeyRestGateway.get_perceel_by_capakey | def get_perceel_by_capakey(self, capakey):
'''
Get a `perceel`.
:param capakey: An capakey for a `perceel`.
:rtype: :class:`Perceel`
'''
def creator():
url = self.base_url + '/parcel/%s' % capakey
h = self.base_headers
p = {
... | python | def get_perceel_by_capakey(self, capakey):
'''
Get a `perceel`.
:param capakey: An capakey for a `perceel`.
:rtype: :class:`Perceel`
'''
def creator():
url = self.base_url + '/parcel/%s' % capakey
h = self.base_headers
p = {
... | [
"def",
"get_perceel_by_capakey",
"(",
"self",
",",
"capakey",
")",
":",
"def",
"creator",
"(",
")",
":",
"url",
"=",
"self",
".",
"base_url",
"+",
"'/parcel/%s'",
"%",
"capakey",
"h",
"=",
"self",
".",
"base_headers",
"p",
"=",
"{",
"'geometry'",
":",
... | Get a `perceel`.
:param capakey: An capakey for a `perceel`.
:rtype: :class:`Perceel` | [
"Get",
"a",
"perceel",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L450-L492 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | Afdeling.set_gateway | def set_gateway(self, gateway):
'''
:param crabpy.gateway.capakey.CapakeyGateway gateway: Gateway to use.
'''
self.gateway = gateway
if (self._gemeente is not None):
self._gemeente.set_gateway(gateway) | python | def set_gateway(self, gateway):
'''
:param crabpy.gateway.capakey.CapakeyGateway gateway: Gateway to use.
'''
self.gateway = gateway
if (self._gemeente is not None):
self._gemeente.set_gateway(gateway) | [
"def",
"set_gateway",
"(",
"self",
",",
"gateway",
")",
":",
"self",
".",
"gateway",
"=",
"gateway",
"if",
"(",
"self",
".",
"_gemeente",
"is",
"not",
"None",
")",
":",
"self",
".",
"_gemeente",
".",
"set_gateway",
"(",
"gateway",
")"
] | :param crabpy.gateway.capakey.CapakeyGateway gateway: Gateway to use. | [
":",
"param",
"crabpy",
".",
"gateway",
".",
"capakey",
".",
"CapakeyGateway",
"gateway",
":",
"Gateway",
"to",
"use",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L649-L655 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | Sectie.set_gateway | def set_gateway(self, gateway):
'''
:param crabpy.gateway.capakey.CapakeyGateway gateway: Gateway to use.
'''
self.gateway = gateway
self.afdeling.set_gateway(gateway) | python | def set_gateway(self, gateway):
'''
:param crabpy.gateway.capakey.CapakeyGateway gateway: Gateway to use.
'''
self.gateway = gateway
self.afdeling.set_gateway(gateway) | [
"def",
"set_gateway",
"(",
"self",
",",
"gateway",
")",
":",
"self",
".",
"gateway",
"=",
"gateway",
"self",
".",
"afdeling",
".",
"set_gateway",
"(",
"gateway",
")"
] | :param crabpy.gateway.capakey.CapakeyGateway gateway: Gateway to use. | [
":",
"param",
"crabpy",
".",
"gateway",
".",
"capakey",
".",
"CapakeyGateway",
"gateway",
":",
"Gateway",
"to",
"use",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L740-L745 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | Perceel.set_gateway | def set_gateway(self, gateway):
'''
:param crabpy.gateway.capakey.CapakeyGateway gateway: Gateway to use.
'''
self.gateway = gateway
self.sectie.set_gateway(gateway) | python | def set_gateway(self, gateway):
'''
:param crabpy.gateway.capakey.CapakeyGateway gateway: Gateway to use.
'''
self.gateway = gateway
self.sectie.set_gateway(gateway) | [
"def",
"set_gateway",
"(",
"self",
",",
"gateway",
")",
":",
"self",
".",
"gateway",
"=",
"gateway",
"self",
".",
"sectie",
".",
"set_gateway",
"(",
"gateway",
")"
] | :param crabpy.gateway.capakey.CapakeyGateway gateway: Gateway to use. | [
":",
"param",
"crabpy",
".",
"gateway",
".",
"capakey",
".",
"CapakeyGateway",
"gateway",
":",
"Gateway",
"to",
"use",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L827-L832 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | Perceel._split_capakey | def _split_capakey(self):
'''
Split a capakey into more readable elements.
Splits a capakey into it's grondnummer, bisnummer, exponent and macht.
'''
import re
match = re.match(
r"^[0-9]{5}[A-Z]{1}([0-9]{4})\/([0-9]{2})([A-Z\_]{1})([0-9]{3})$",
se... | python | def _split_capakey(self):
'''
Split a capakey into more readable elements.
Splits a capakey into it's grondnummer, bisnummer, exponent and macht.
'''
import re
match = re.match(
r"^[0-9]{5}[A-Z]{1}([0-9]{4})\/([0-9]{2})([A-Z\_]{1})([0-9]{3})$",
se... | [
"def",
"_split_capakey",
"(",
"self",
")",
":",
"import",
"re",
"match",
"=",
"re",
".",
"match",
"(",
"r\"^[0-9]{5}[A-Z]{1}([0-9]{4})\\/([0-9]{2})([A-Z\\_]{1})([0-9]{3})$\"",
",",
"self",
".",
"capakey",
")",
"if",
"match",
":",
"self",
".",
"grondnummer",
"=",
... | Split a capakey into more readable elements.
Splits a capakey into it's grondnummer, bisnummer, exponent and macht. | [
"Split",
"a",
"capakey",
"into",
"more",
"readable",
"elements",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L875-L894 |
ereOn/azmq | azmq/crypto.py | requires_libsodium | def requires_libsodium(func):
"""
Mark a function as requiring libsodium.
If no libsodium support is detected, a `RuntimeError` is thrown.
"""
@wraps(func)
def wrapper(*args, **kwargs):
libsodium_check()
return func(*args, **kwargs)
return wrapper | python | def requires_libsodium(func):
"""
Mark a function as requiring libsodium.
If no libsodium support is detected, a `RuntimeError` is thrown.
"""
@wraps(func)
def wrapper(*args, **kwargs):
libsodium_check()
return func(*args, **kwargs)
return wrapper | [
"def",
"requires_libsodium",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"libsodium_check",
"(",
")",
"return",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"... | Mark a function as requiring libsodium.
If no libsodium support is detected, a `RuntimeError` is thrown. | [
"Mark",
"a",
"function",
"as",
"requiring",
"libsodium",
"."
] | train | https://github.com/ereOn/azmq/blob/9f40d6d721eea7f7659ec6cc668811976db59854/azmq/crypto.py#L68-L79 |
publysher/rdflib-django | src/rdflib_django/admin.py | NamespaceAdmin.has_delete_permission | def has_delete_permission(self, request, obj=None):
"""
Default namespaces cannot be deleted.
"""
if obj is not None and obj.fixed:
return False
return super(NamespaceAdmin, self).has_delete_permission(request, obj) | python | def has_delete_permission(self, request, obj=None):
"""
Default namespaces cannot be deleted.
"""
if obj is not None and obj.fixed:
return False
return super(NamespaceAdmin, self).has_delete_permission(request, obj) | [
"def",
"has_delete_permission",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"if",
"obj",
"is",
"not",
"None",
"and",
"obj",
".",
"fixed",
":",
"return",
"False",
"return",
"super",
"(",
"NamespaceAdmin",
",",
"self",
")",
".",
"has_... | Default namespaces cannot be deleted. | [
"Default",
"namespaces",
"cannot",
"be",
"deleted",
"."
] | train | https://github.com/publysher/rdflib-django/blob/e26992af75f96ef27a6ceaf820574e3bca645953/src/rdflib_django/admin.py#L30-L37 |
xolox/python-vcs-repo-mgr | setup.py | get_install_requires | def get_install_requires():
"""Add conditional dependencies (when creating source distributions)."""
install_requires = get_requirements('requirements.txt')
if 'bdist_wheel' not in sys.argv:
if sys.version_info[0] == 2:
# On Python 2.6 and 2.7 we pull in Bazaar.
install_requi... | python | def get_install_requires():
"""Add conditional dependencies (when creating source distributions)."""
install_requires = get_requirements('requirements.txt')
if 'bdist_wheel' not in sys.argv:
if sys.version_info[0] == 2:
# On Python 2.6 and 2.7 we pull in Bazaar.
install_requi... | [
"def",
"get_install_requires",
"(",
")",
":",
"install_requires",
"=",
"get_requirements",
"(",
"'requirements.txt'",
")",
"if",
"'bdist_wheel'",
"not",
"in",
"sys",
".",
"argv",
":",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"==",
"2",
":",
"# On Pyt... | Add conditional dependencies (when creating source distributions). | [
"Add",
"conditional",
"dependencies",
"(",
"when",
"creating",
"source",
"distributions",
")",
"."
] | train | https://github.com/xolox/python-vcs-repo-mgr/blob/fdad2441a3e7ba5deeeddfa1c2f5ebc00c393aed/setup.py#L48-L63 |
django-blog-zinnia/zinnia-wysiwyg-wymeditor | zinnia_wymeditor/admin.py | EntryAdminWYMEditorMixin.get_urls | def get_urls(self):
"""
Overload the admin's urls for WYMEditor.
"""
entry_admin_urls = super(EntryAdminWYMEditorMixin, self).get_urls()
urls = [
url(r'^wymeditor/$',
self.admin_site.admin_view(self.wymeditor),
name='zinnia_entry_wymedi... | python | def get_urls(self):
"""
Overload the admin's urls for WYMEditor.
"""
entry_admin_urls = super(EntryAdminWYMEditorMixin, self).get_urls()
urls = [
url(r'^wymeditor/$',
self.admin_site.admin_view(self.wymeditor),
name='zinnia_entry_wymedi... | [
"def",
"get_urls",
"(",
"self",
")",
":",
"entry_admin_urls",
"=",
"super",
"(",
"EntryAdminWYMEditorMixin",
",",
"self",
")",
".",
"get_urls",
"(",
")",
"urls",
"=",
"[",
"url",
"(",
"r'^wymeditor/$'",
",",
"self",
".",
"admin_site",
".",
"admin_view",
"(... | Overload the admin's urls for WYMEditor. | [
"Overload",
"the",
"admin",
"s",
"urls",
"for",
"WYMEditor",
"."
] | train | https://github.com/django-blog-zinnia/zinnia-wysiwyg-wymeditor/blob/3461a5760c1643460ce7a6236cdc200dccdcd838/zinnia_wymeditor/admin.py#L29-L39 |
django-blog-zinnia/zinnia-wysiwyg-wymeditor | zinnia_wymeditor/admin.py | EntryAdminWYMEditorMixin._media | def _media(self):
"""
The medias needed to enhance the admin page.
"""
def static_url(url):
return staticfiles_storage.url('zinnia_wymeditor/%s' % url)
media = super(EntryAdminWYMEditorMixin, self).media
media += Media(
js=(static_url('js/jquery.... | python | def _media(self):
"""
The medias needed to enhance the admin page.
"""
def static_url(url):
return staticfiles_storage.url('zinnia_wymeditor/%s' % url)
media = super(EntryAdminWYMEditorMixin, self).media
media += Media(
js=(static_url('js/jquery.... | [
"def",
"_media",
"(",
"self",
")",
":",
"def",
"static_url",
"(",
"url",
")",
":",
"return",
"staticfiles_storage",
".",
"url",
"(",
"'zinnia_wymeditor/%s'",
"%",
"url",
")",
"media",
"=",
"super",
"(",
"EntryAdminWYMEditorMixin",
",",
"self",
")",
".",
"m... | The medias needed to enhance the admin page. | [
"The",
"medias",
"needed",
"to",
"enhance",
"the",
"admin",
"page",
"."
] | train | https://github.com/django-blog-zinnia/zinnia-wysiwyg-wymeditor/blob/3461a5760c1643460ce7a6236cdc200dccdcd838/zinnia_wymeditor/admin.py#L41-L56 |
ttinies/sc2gameLobby | sc2gameLobby/setScenario.py | launchEditor | def launchEditor(mapObj):
"""
PURPOSE: launch the editor using a specific map object
INPUT: mapObj (sc2maptool.mapRecord.MapRecord)
"""
cfg = Config()
if cfg.is64bit: selectedArchitecture = c.SUPPORT_64_BIT_TERMS
else: selectedArchitecture = c.SUPPORT_32_BIT_TERMS
editorCmd =... | python | def launchEditor(mapObj):
"""
PURPOSE: launch the editor using a specific map object
INPUT: mapObj (sc2maptool.mapRecord.MapRecord)
"""
cfg = Config()
if cfg.is64bit: selectedArchitecture = c.SUPPORT_64_BIT_TERMS
else: selectedArchitecture = c.SUPPORT_32_BIT_TERMS
editorCmd =... | [
"def",
"launchEditor",
"(",
"mapObj",
")",
":",
"cfg",
"=",
"Config",
"(",
")",
"if",
"cfg",
".",
"is64bit",
":",
"selectedArchitecture",
"=",
"c",
".",
"SUPPORT_64_BIT_TERMS",
"else",
":",
"selectedArchitecture",
"=",
"c",
".",
"SUPPORT_32_BIT_TERMS",
"editor... | PURPOSE: launch the editor using a specific map object
INPUT: mapObj (sc2maptool.mapRecord.MapRecord) | [
"PURPOSE",
":",
"launch",
"the",
"editor",
"using",
"a",
"specific",
"map",
"object",
"INPUT",
":",
"mapObj",
"(",
"sc2maptool",
".",
"mapRecord",
".",
"MapRecord",
")"
] | train | https://github.com/ttinies/sc2gameLobby/blob/5352d51d53ddeb4858e92e682da89c4434123e52/sc2gameLobby/setScenario.py#L20-L45 |
ttinies/sc2gameLobby | sc2gameLobby/setScenario.py | initScenario | def initScenario(controller, scenario, thisPlayerID, debug=False):
"""once in the in_game state, use the controller to set up the scenario"""
############################################################################
def createUnitsWithTags(unitList, existingUnits={}, maxTries=25):
"""create each ... | python | def initScenario(controller, scenario, thisPlayerID, debug=False):
"""once in the in_game state, use the controller to set up the scenario"""
############################################################################
def createUnitsWithTags(unitList, existingUnits={}, maxTries=25):
"""create each ... | [
"def",
"initScenario",
"(",
"controller",
",",
"scenario",
",",
"thisPlayerID",
",",
"debug",
"=",
"False",
")",
":",
"############################################################################",
"def",
"createUnitsWithTags",
"(",
"unitList",
",",
"existingUnits",
"=",
... | once in the in_game state, use the controller to set up the scenario | [
"once",
"in",
"the",
"in_game",
"state",
"use",
"the",
"controller",
"to",
"set",
"up",
"the",
"scenario"
] | train | https://github.com/ttinies/sc2gameLobby/blob/5352d51d53ddeb4858e92e682da89c4434123e52/sc2gameLobby/setScenario.py#L49-L214 |
nivbend/mock-open | mock_open/mocks.py | FileLikeMock.set_properties | def set_properties(self, path, mode):
"""Set file's properties (name and mode).
This function is also in charge of swapping between textual and
binary streams.
"""
self.name = path
self.mode = mode
if 'b' in self.mode:
if not isinstance(self.read_dat... | python | def set_properties(self, path, mode):
"""Set file's properties (name and mode).
This function is also in charge of swapping between textual and
binary streams.
"""
self.name = path
self.mode = mode
if 'b' in self.mode:
if not isinstance(self.read_dat... | [
"def",
"set_properties",
"(",
"self",
",",
"path",
",",
"mode",
")",
":",
"self",
".",
"name",
"=",
"path",
"self",
".",
"mode",
"=",
"mode",
"if",
"'b'",
"in",
"self",
".",
"mode",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"read_data",
","... | Set file's properties (name and mode).
This function is also in charge of swapping between textual and
binary streams. | [
"Set",
"file",
"s",
"properties",
"(",
"name",
"and",
"mode",
")",
"."
] | train | https://github.com/nivbend/mock-open/blob/eb7c9484b8c0ed58ba81ad04f44974e3dfa1b023/mock_open/mocks.py#L77-L91 |
nivbend/mock-open | mock_open/mocks.py | FileLikeMock.reset_mock | def reset_mock(self, visited=None):
"""Reset the default tell/read/write/etc side effects."""
# In some versions of the mock library, `reset_mock` takes an argument
# and in some it doesn't. We try to handle all situations.
if visited is not None:
super(FileLikeMock, self).re... | python | def reset_mock(self, visited=None):
"""Reset the default tell/read/write/etc side effects."""
# In some versions of the mock library, `reset_mock` takes an argument
# and in some it doesn't. We try to handle all situations.
if visited is not None:
super(FileLikeMock, self).re... | [
"def",
"reset_mock",
"(",
"self",
",",
"visited",
"=",
"None",
")",
":",
"# In some versions of the mock library, `reset_mock` takes an argument",
"# and in some it doesn't. We try to handle all situations.",
"if",
"visited",
"is",
"not",
"None",
":",
"super",
"(",
"FileLikeM... | Reset the default tell/read/write/etc side effects. | [
"Reset",
"the",
"default",
"tell",
"/",
"read",
"/",
"write",
"/",
"etc",
"side",
"effects",
"."
] | train | https://github.com/nivbend/mock-open/blob/eb7c9484b8c0ed58ba81ad04f44974e3dfa1b023/mock_open/mocks.py#L93-L104 |
nivbend/mock-open | mock_open/mocks.py | MockOpen._get_child_mock | def _get_child_mock(self, **kws):
"""Create a new FileLikeMock instance.
The new mock will inherit the parent's side_effect and read_data
attributes.
"""
kws.update({
'_new_parent': self,
'side_effect': self._mock_side_effect,
'read_data': sel... | python | def _get_child_mock(self, **kws):
"""Create a new FileLikeMock instance.
The new mock will inherit the parent's side_effect and read_data
attributes.
"""
kws.update({
'_new_parent': self,
'side_effect': self._mock_side_effect,
'read_data': sel... | [
"def",
"_get_child_mock",
"(",
"self",
",",
"*",
"*",
"kws",
")",
":",
"kws",
".",
"update",
"(",
"{",
"'_new_parent'",
":",
"self",
",",
"'side_effect'",
":",
"self",
".",
"_mock_side_effect",
",",
"'read_data'",
":",
"self",
".",
"__read_data",
",",
"}... | Create a new FileLikeMock instance.
The new mock will inherit the parent's side_effect and read_data
attributes. | [
"Create",
"a",
"new",
"FileLikeMock",
"instance",
"."
] | train | https://github.com/nivbend/mock-open/blob/eb7c9484b8c0ed58ba81ad04f44974e3dfa1b023/mock_open/mocks.py#L178-L189 |
ereOn/azmq | azmq/zap.py | ZAPAuthenticator.allow | def allow(self, ip):
"""
Allow the specified IP to connect.
:param ip: The IPv4 or IPv6 address to allow.
"""
self.whitelist.append(ip)
self.blacklist.clear() | python | def allow(self, ip):
"""
Allow the specified IP to connect.
:param ip: The IPv4 or IPv6 address to allow.
"""
self.whitelist.append(ip)
self.blacklist.clear() | [
"def",
"allow",
"(",
"self",
",",
"ip",
")",
":",
"self",
".",
"whitelist",
".",
"append",
"(",
"ip",
")",
"self",
".",
"blacklist",
".",
"clear",
"(",
")"
] | Allow the specified IP to connect.
:param ip: The IPv4 or IPv6 address to allow. | [
"Allow",
"the",
"specified",
"IP",
"to",
"connect",
"."
] | train | https://github.com/ereOn/azmq/blob/9f40d6d721eea7f7659ec6cc668811976db59854/azmq/zap.py#L228-L235 |
ereOn/azmq | azmq/zap.py | ZAPAuthenticator.deny | def deny(self, ip):
"""
Allow the specified IP to connect.
:param ip: The IPv4 or IPv6 address to allow.
"""
self.blacklist.append(ip)
self.whitelist.clear() | python | def deny(self, ip):
"""
Allow the specified IP to connect.
:param ip: The IPv4 or IPv6 address to allow.
"""
self.blacklist.append(ip)
self.whitelist.clear() | [
"def",
"deny",
"(",
"self",
",",
"ip",
")",
":",
"self",
".",
"blacklist",
".",
"append",
"(",
"ip",
")",
"self",
".",
"whitelist",
".",
"clear",
"(",
")"
] | Allow the specified IP to connect.
:param ip: The IPv4 or IPv6 address to allow. | [
"Allow",
"the",
"specified",
"IP",
"to",
"connect",
"."
] | train | https://github.com/ereOn/azmq/blob/9f40d6d721eea7f7659ec6cc668811976db59854/azmq/zap.py#L237-L244 |
ereOn/azmq | azmq/zap.py | ZAPAuthenticator.on_request | async def on_request(
self,
domain,
address,
identity,
mechanism,
credentials,
):
"""
Handle a ZAP request.
"""
logger.debug(
"Request in domain %s for %s (%r): %r (%r)",
domain,
address,
... | python | async def on_request(
self,
domain,
address,
identity,
mechanism,
credentials,
):
"""
Handle a ZAP request.
"""
logger.debug(
"Request in domain %s for %s (%r): %r (%r)",
domain,
address,
... | [
"async",
"def",
"on_request",
"(",
"self",
",",
"domain",
",",
"address",
",",
"identity",
",",
"mechanism",
",",
"credentials",
",",
")",
":",
"logger",
".",
"debug",
"(",
"\"Request in domain %s for %s (%r): %r (%r)\"",
",",
"domain",
",",
"address",
",",
"i... | Handle a ZAP request. | [
"Handle",
"a",
"ZAP",
"request",
"."
] | train | https://github.com/ereOn/azmq/blob/9f40d6d721eea7f7659ec6cc668811976db59854/azmq/zap.py#L283-L338 |
payplug/payplug-python | payplug/resources.py | APIResource.factory | def factory(data):
"""
Try to reconstruct the APIResource from its data.
:param data: The APIResource data
:type data: dict
:return: The guessed APIResource
:raise
exceptions.UnkownAPIResource when it's impossible to reconstruct the APIResource from its dat... | python | def factory(data):
"""
Try to reconstruct the APIResource from its data.
:param data: The APIResource data
:type data: dict
:return: The guessed APIResource
:raise
exceptions.UnkownAPIResource when it's impossible to reconstruct the APIResource from its dat... | [
"def",
"factory",
"(",
"data",
")",
":",
"if",
"'object'",
"not",
"in",
"data",
":",
"raise",
"exceptions",
".",
"UnknownAPIResource",
"(",
"'Missing `object` key in resource.'",
")",
"for",
"reconstituable_api_resource_type",
"in",
"ReconstituableAPIResource",
".",
"... | Try to reconstruct the APIResource from its data.
:param data: The APIResource data
:type data: dict
:return: The guessed APIResource
:raise
exceptions.UnkownAPIResource when it's impossible to reconstruct the APIResource from its data. | [
"Try",
"to",
"reconstruct",
"the",
"APIResource",
"from",
"its",
"data",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/resources.py#L52-L71 |
payplug/payplug-python | payplug/resources.py | APIResource._initialize | def _initialize(self, **resource_attributes):
"""
Initialize a resource.
Default behavior is just to set all the attributes. You may want to override this.
:param resource_attributes: The resource attributes
"""
self._set_attributes(**resource_attributes)
for att... | python | def _initialize(self, **resource_attributes):
"""
Initialize a resource.
Default behavior is just to set all the attributes. You may want to override this.
:param resource_attributes: The resource attributes
"""
self._set_attributes(**resource_attributes)
for att... | [
"def",
"_initialize",
"(",
"self",
",",
"*",
"*",
"resource_attributes",
")",
":",
"self",
".",
"_set_attributes",
"(",
"*",
"*",
"resource_attributes",
")",
"for",
"attribute",
",",
"attribute_type",
"in",
"list",
"(",
"self",
".",
"_mapper",
".",
"items",
... | Initialize a resource.
Default behavior is just to set all the attributes. You may want to override this.
:param resource_attributes: The resource attributes | [
"Initialize",
"a",
"resource",
".",
"Default",
"behavior",
"is",
"just",
"to",
"set",
"all",
"the",
"attributes",
".",
"You",
"may",
"want",
"to",
"override",
"this",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/resources.py#L81-L91 |
payplug/payplug-python | payplug/resources.py | Payment._mapper | def _mapper(self):
"""
Maps payment attributes to their specific types.
:see :func:`~APIResource._mapper`
"""
return {
'card': Payment.Card,
'customer': Payment.Customer,
'hosted_payment': Payment.HostedPayment,
'notification': Pay... | python | def _mapper(self):
"""
Maps payment attributes to their specific types.
:see :func:`~APIResource._mapper`
"""
return {
'card': Payment.Card,
'customer': Payment.Customer,
'hosted_payment': Payment.HostedPayment,
'notification': Pay... | [
"def",
"_mapper",
"(",
"self",
")",
":",
"return",
"{",
"'card'",
":",
"Payment",
".",
"Card",
",",
"'customer'",
":",
"Payment",
".",
"Customer",
",",
"'hosted_payment'",
":",
"Payment",
".",
"HostedPayment",
",",
"'notification'",
":",
"Payment",
".",
"N... | Maps payment attributes to their specific types.
:see :func:`~APIResource._mapper` | [
"Maps",
"payment",
"attributes",
"to",
"their",
"specific",
"types",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/resources.py#L143-L155 |
payplug/payplug-python | payplug/resources.py | Payment.get_consistent_resource | def get_consistent_resource(self):
"""
:return a payment that you can trust.
:rtype Payment
"""
http_client = HttpClient()
response, _ = http_client.get(routes.url(routes.PAYMENT_RESOURCE, resource_id=self.id))
return Payment(**response) | python | def get_consistent_resource(self):
"""
:return a payment that you can trust.
:rtype Payment
"""
http_client = HttpClient()
response, _ = http_client.get(routes.url(routes.PAYMENT_RESOURCE, resource_id=self.id))
return Payment(**response) | [
"def",
"get_consistent_resource",
"(",
"self",
")",
":",
"http_client",
"=",
"HttpClient",
"(",
")",
"response",
",",
"_",
"=",
"http_client",
".",
"get",
"(",
"routes",
".",
"url",
"(",
"routes",
".",
"PAYMENT_RESOURCE",
",",
"resource_id",
"=",
"self",
"... | :return a payment that you can trust.
:rtype Payment | [
":",
"return",
"a",
"payment",
"that",
"you",
"can",
"trust",
".",
":",
"rtype",
"Payment"
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/resources.py#L157-L164 |
payplug/payplug-python | payplug/resources.py | Refund.get_consistent_resource | def get_consistent_resource(self):
"""
:return a refund that you can trust.
:rtype Refund
"""
http_client = HttpClient()
response, _ = http_client.get(
routes.url(routes.REFUND_RESOURCE, resource_id=self.id, payment_id=self.payment_id)
)
return... | python | def get_consistent_resource(self):
"""
:return a refund that you can trust.
:rtype Refund
"""
http_client = HttpClient()
response, _ = http_client.get(
routes.url(routes.REFUND_RESOURCE, resource_id=self.id, payment_id=self.payment_id)
)
return... | [
"def",
"get_consistent_resource",
"(",
"self",
")",
":",
"http_client",
"=",
"HttpClient",
"(",
")",
"response",
",",
"_",
"=",
"http_client",
".",
"get",
"(",
"routes",
".",
"url",
"(",
"routes",
".",
"REFUND_RESOURCE",
",",
"resource_id",
"=",
"self",
".... | :return a refund that you can trust.
:rtype Refund | [
":",
"return",
"a",
"refund",
"that",
"you",
"can",
"trust",
".",
":",
"rtype",
"Refund"
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/resources.py#L232-L241 |
payplug/payplug-python | payplug/resources.py | Customer.list_cards | def list_cards(self, *args, **kwargs):
"""
List the cards of the customer.
:param page: the page number
:type page: int|None
:param per_page: number of customers per page. It's a good practice to increase this number if you know that you
will need a lot of payments.
... | python | def list_cards(self, *args, **kwargs):
"""
List the cards of the customer.
:param page: the page number
:type page: int|None
:param per_page: number of customers per page. It's a good practice to increase this number if you know that you
will need a lot of payments.
... | [
"def",
"list_cards",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"payplug",
".",
"Card",
".",
"list",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | List the cards of the customer.
:param page: the page number
:type page: int|None
:param per_page: number of customers per page. It's a good practice to increase this number if you know that you
will need a lot of payments.
:type per_page: int|None
:return: The cards of ... | [
"List",
"the",
"cards",
"of",
"the",
"customer",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/resources.py#L274-L286 |
payplug/payplug-python | payplug/resources.py | APIResourceCollection._initialize | def _initialize(self, **resource_attributes):
"""
Initialize the collection.
:param resource_attributes: API resource parameters
"""
super(APIResourceCollection, self)._initialize(**resource_attributes)
dict_list = self.data
self.data = []
for resource i... | python | def _initialize(self, **resource_attributes):
"""
Initialize the collection.
:param resource_attributes: API resource parameters
"""
super(APIResourceCollection, self)._initialize(**resource_attributes)
dict_list = self.data
self.data = []
for resource i... | [
"def",
"_initialize",
"(",
"self",
",",
"*",
"*",
"resource_attributes",
")",
":",
"super",
"(",
"APIResourceCollection",
",",
"self",
")",
".",
"_initialize",
"(",
"*",
"*",
"resource_attributes",
")",
"dict_list",
"=",
"self",
".",
"data",
"self",
".",
"... | Initialize the collection.
:param resource_attributes: API resource parameters | [
"Initialize",
"the",
"collection",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/resources.py#L317-L328 |
xolox/python-vcs-repo-mgr | vcs_repo_mgr/cli.py | main | def main():
"""The command line interface of the ``vcs-tool`` program."""
# Initialize logging to the terminal.
coloredlogs.install()
# Command line option defaults.
repository = None
revision = None
actions = []
# Parse the command line arguments.
try:
options, arguments = g... | python | def main():
"""The command line interface of the ``vcs-tool`` program."""
# Initialize logging to the terminal.
coloredlogs.install()
# Command line option defaults.
repository = None
revision = None
actions = []
# Parse the command line arguments.
try:
options, arguments = g... | [
"def",
"main",
"(",
")",
":",
"# Initialize logging to the terminal.",
"coloredlogs",
".",
"install",
"(",
")",
"# Command line option defaults.",
"repository",
"=",
"None",
"revision",
"=",
"None",
"actions",
"=",
"[",
"]",
"# Parse the command line arguments.",
"try",... | The command line interface of the ``vcs-tool`` program. | [
"The",
"command",
"line",
"interface",
"of",
"the",
"vcs",
"-",
"tool",
"program",
"."
] | train | https://github.com/xolox/python-vcs-repo-mgr/blob/fdad2441a3e7ba5deeeddfa1c2f5ebc00c393aed/vcs_repo_mgr/cli.py#L164-L257 |
danielfrg/datasciencebox | datasciencebox/core/utils.py | retry | def retry(retries=10, wait=5, catch=None):
"""
Decorator to retry on exceptions raised
"""
catch = catch or (Exception,)
def real_retry(function):
def wrapper(*args, **kwargs):
for _ in range(retries):
try:
ret = function(*args, **kwargs)
... | python | def retry(retries=10, wait=5, catch=None):
"""
Decorator to retry on exceptions raised
"""
catch = catch or (Exception,)
def real_retry(function):
def wrapper(*args, **kwargs):
for _ in range(retries):
try:
ret = function(*args, **kwargs)
... | [
"def",
"retry",
"(",
"retries",
"=",
"10",
",",
"wait",
"=",
"5",
",",
"catch",
"=",
"None",
")",
":",
"catch",
"=",
"catch",
"or",
"(",
"Exception",
",",
")",
"def",
"real_retry",
"(",
"function",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",... | Decorator to retry on exceptions raised | [
"Decorator",
"to",
"retry",
"on",
"exceptions",
"raised"
] | train | https://github.com/danielfrg/datasciencebox/blob/6b7aa642c6616a46547035fcb815acc1de605a6f/datasciencebox/core/utils.py#L14-L36 |
danielfrg/datasciencebox | datasciencebox/core/utils.py | replace_all | def replace_all(filepath, searchExp, replaceExp):
"""
Replace all the ocurrences (in a file) of a string with another value.
"""
for line in fileinput.input(filepath, inplace=1):
if searchExp in line:
line = line.replace(searchExp, replaceExp)
sys.stdout.write(line) | python | def replace_all(filepath, searchExp, replaceExp):
"""
Replace all the ocurrences (in a file) of a string with another value.
"""
for line in fileinput.input(filepath, inplace=1):
if searchExp in line:
line = line.replace(searchExp, replaceExp)
sys.stdout.write(line) | [
"def",
"replace_all",
"(",
"filepath",
",",
"searchExp",
",",
"replaceExp",
")",
":",
"for",
"line",
"in",
"fileinput",
".",
"input",
"(",
"filepath",
",",
"inplace",
"=",
"1",
")",
":",
"if",
"searchExp",
"in",
"line",
":",
"line",
"=",
"line",
".",
... | Replace all the ocurrences (in a file) of a string with another value. | [
"Replace",
"all",
"the",
"ocurrences",
"(",
"in",
"a",
"file",
")",
"of",
"a",
"string",
"with",
"another",
"value",
"."
] | train | https://github.com/danielfrg/datasciencebox/blob/6b7aa642c6616a46547035fcb815acc1de605a6f/datasciencebox/core/utils.py#L39-L46 |
ereOn/azmq | azmq/connections/base.py | BaseConnection.discard_incoming_messages | def discard_incoming_messages(self):
"""
Discard all incoming messages for the time of the context manager.
"""
# Flush any received message so far.
self.inbox.clear()
# This allows nesting of discard_incoming_messages() calls.
previous = self._discard_incoming_m... | python | def discard_incoming_messages(self):
"""
Discard all incoming messages for the time of the context manager.
"""
# Flush any received message so far.
self.inbox.clear()
# This allows nesting of discard_incoming_messages() calls.
previous = self._discard_incoming_m... | [
"def",
"discard_incoming_messages",
"(",
"self",
")",
":",
"# Flush any received message so far.",
"self",
".",
"inbox",
".",
"clear",
"(",
")",
"# This allows nesting of discard_incoming_messages() calls.",
"previous",
"=",
"self",
".",
"_discard_incoming_messages",
"self",
... | Discard all incoming messages for the time of the context manager. | [
"Discard",
"all",
"incoming",
"messages",
"for",
"the",
"time",
"of",
"the",
"context",
"manager",
"."
] | train | https://github.com/ereOn/azmq/blob/9f40d6d721eea7f7659ec6cc668811976db59854/azmq/connections/base.py#L135-L149 |
ox-it/django-conneg | django_conneg/http.py | MediaType.provides | def provides(self, imt):
"""
Returns True iff the self is at least as specific as other.
Examples:
application/xhtml+xml provides application/xml, application/*, */*
text/html provides text/*, but not application/xhtml+xml or application/html
"""
return self.type... | python | def provides(self, imt):
"""
Returns True iff the self is at least as specific as other.
Examples:
application/xhtml+xml provides application/xml, application/*, */*
text/html provides text/*, but not application/xhtml+xml or application/html
"""
return self.type... | [
"def",
"provides",
"(",
"self",
",",
"imt",
")",
":",
"return",
"self",
".",
"type",
"[",
":",
"imt",
".",
"specifity",
"]",
"==",
"imt",
".",
"type",
"[",
":",
"imt",
".",
"specifity",
"]"
] | Returns True iff the self is at least as specific as other.
Examples:
application/xhtml+xml provides application/xml, application/*, */*
text/html provides text/*, but not application/xhtml+xml or application/html | [
"Returns",
"True",
"iff",
"the",
"self",
"is",
"at",
"least",
"as",
"specific",
"as",
"other",
"."
] | train | https://github.com/ox-it/django-conneg/blob/4f103932322b3e151fcfdf279f1353dad2049d1f/django_conneg/http.py#L105-L113 |
ox-it/django-conneg | django_conneg/http.py | MediaType.resolve | def resolve(cls, accept, available_renderers):
"""
Resolves a list of accepted MediaTypes and available renderers to the preferred renderer.
Call as MediaType.resolve([MediaType], [renderer]).
"""
assert isinstance(available_renderers, tuple)
accept = sorted(accept)
... | python | def resolve(cls, accept, available_renderers):
"""
Resolves a list of accepted MediaTypes and available renderers to the preferred renderer.
Call as MediaType.resolve([MediaType], [renderer]).
"""
assert isinstance(available_renderers, tuple)
accept = sorted(accept)
... | [
"def",
"resolve",
"(",
"cls",
",",
"accept",
",",
"available_renderers",
")",
":",
"assert",
"isinstance",
"(",
"available_renderers",
",",
"tuple",
")",
"accept",
"=",
"sorted",
"(",
"accept",
")",
"renderers",
",",
"seen",
"=",
"[",
"]",
",",
"set",
"(... | Resolves a list of accepted MediaTypes and available renderers to the preferred renderer.
Call as MediaType.resolve([MediaType], [renderer]). | [
"Resolves",
"a",
"list",
"of",
"accepted",
"MediaTypes",
"and",
"available",
"renderers",
"to",
"the",
"preferred",
"renderer",
"."
] | train | https://github.com/ox-it/django-conneg/blob/4f103932322b3e151fcfdf279f1353dad2049d1f/django_conneg/http.py#L116-L145 |
dcramer/django-static-compiler | src/static_compiler/storage.py | StaticCompilerFileStorage.get_available_name | def get_available_name(self, name):
"""
Deletes the given file if it exists.
"""
if self.exists(name):
self.delete(name)
return name | python | def get_available_name(self, name):
"""
Deletes the given file if it exists.
"""
if self.exists(name):
self.delete(name)
return name | [
"def",
"get_available_name",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"exists",
"(",
"name",
")",
":",
"self",
".",
"delete",
"(",
"name",
")",
"return",
"name"
] | Deletes the given file if it exists. | [
"Deletes",
"the",
"given",
"file",
"if",
"it",
"exists",
"."
] | train | https://github.com/dcramer/django-static-compiler/blob/7218d30e1b4eb88b7a8683ae5748f6a71c502b81/src/static_compiler/storage.py#L30-L36 |
dcramer/django-static-compiler | src/static_compiler/storage.py | StaticCompilerFileStorage.delete | def delete(self, name):
"""
Handle deletion race condition present in Django prior to 1.4
https://code.djangoproject.com/ticket/16108
"""
try:
super(StaticCompilerFileStorage, self).delete(name)
except OSError, e:
if e.errno != errno.ENOENT:
... | python | def delete(self, name):
"""
Handle deletion race condition present in Django prior to 1.4
https://code.djangoproject.com/ticket/16108
"""
try:
super(StaticCompilerFileStorage, self).delete(name)
except OSError, e:
if e.errno != errno.ENOENT:
... | [
"def",
"delete",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"super",
"(",
"StaticCompilerFileStorage",
",",
"self",
")",
".",
"delete",
"(",
"name",
")",
"except",
"OSError",
",",
"e",
":",
"if",
"e",
".",
"errno",
"!=",
"errno",
".",
"ENOENT",
... | Handle deletion race condition present in Django prior to 1.4
https://code.djangoproject.com/ticket/16108 | [
"Handle",
"deletion",
"race",
"condition",
"present",
"in",
"Django",
"prior",
"to",
"1",
".",
"4",
"https",
":",
"//",
"code",
".",
"djangoproject",
".",
"com",
"/",
"ticket",
"/",
"16108"
] | train | https://github.com/dcramer/django-static-compiler/blob/7218d30e1b4eb88b7a8683ae5748f6a71c502b81/src/static_compiler/storage.py#L38-L47 |
ereOn/azmq | azmq/multiplexer.py | Multiplexer.add_socket | def add_socket(self, socket):
"""
Add a socket to the multiplexer.
:param socket: The socket. If it was added already, it won't be added a
second time.
"""
if socket not in self._sockets:
self._sockets.add(socket)
socket.on_closed.connect(self... | python | def add_socket(self, socket):
"""
Add a socket to the multiplexer.
:param socket: The socket. If it was added already, it won't be added a
second time.
"""
if socket not in self._sockets:
self._sockets.add(socket)
socket.on_closed.connect(self... | [
"def",
"add_socket",
"(",
"self",
",",
"socket",
")",
":",
"if",
"socket",
"not",
"in",
"self",
".",
"_sockets",
":",
"self",
".",
"_sockets",
".",
"add",
"(",
"socket",
")",
"socket",
".",
"on_closed",
".",
"connect",
"(",
"self",
".",
"remove_socket"... | Add a socket to the multiplexer.
:param socket: The socket. If it was added already, it won't be added a
second time. | [
"Add",
"a",
"socket",
"to",
"the",
"multiplexer",
"."
] | train | https://github.com/ereOn/azmq/blob/9f40d6d721eea7f7659ec6cc668811976db59854/azmq/multiplexer.py#L18-L27 |
ereOn/azmq | azmq/multiplexer.py | Multiplexer.remove_socket | def remove_socket(self, socket):
"""
Remove a socket from the multiplexer.
:param socket: The socket. If it was removed already or if it wasn't
added, the call does nothing.
"""
if socket in self._sockets:
socket.on_closed.disconnect(self.remove_socket)
... | python | def remove_socket(self, socket):
"""
Remove a socket from the multiplexer.
:param socket: The socket. If it was removed already or if it wasn't
added, the call does nothing.
"""
if socket in self._sockets:
socket.on_closed.disconnect(self.remove_socket)
... | [
"def",
"remove_socket",
"(",
"self",
",",
"socket",
")",
":",
"if",
"socket",
"in",
"self",
".",
"_sockets",
":",
"socket",
".",
"on_closed",
".",
"disconnect",
"(",
"self",
".",
"remove_socket",
")",
"self",
".",
"_sockets",
".",
"remove",
"(",
"socket"... | Remove a socket from the multiplexer.
:param socket: The socket. If it was removed already or if it wasn't
added, the call does nothing. | [
"Remove",
"a",
"socket",
"from",
"the",
"multiplexer",
"."
] | train | https://github.com/ereOn/azmq/blob/9f40d6d721eea7f7659ec6cc668811976db59854/azmq/multiplexer.py#L29-L38 |
ereOn/azmq | azmq/multiplexer.py | Multiplexer.recv_multipart | async def recv_multipart(self):
"""
Read from all the associated sockets.
:returns: A list of tuples (socket, frames) for each socket that
returned a result.
"""
if not self._sockets:
return []
results = []
async def recv_and_store(socke... | python | async def recv_multipart(self):
"""
Read from all the associated sockets.
:returns: A list of tuples (socket, frames) for each socket that
returned a result.
"""
if not self._sockets:
return []
results = []
async def recv_and_store(socke... | [
"async",
"def",
"recv_multipart",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_sockets",
":",
"return",
"[",
"]",
"results",
"=",
"[",
"]",
"async",
"def",
"recv_and_store",
"(",
"socket",
")",
":",
"frames",
"=",
"await",
"socket",
".",
"recv_mu... | Read from all the associated sockets.
:returns: A list of tuples (socket, frames) for each socket that
returned a result. | [
"Read",
"from",
"all",
"the",
"associated",
"sockets",
"."
] | train | https://github.com/ereOn/azmq/blob/9f40d6d721eea7f7659ec6cc668811976db59854/azmq/multiplexer.py#L41-L72 |
rodynnz/xccdf | src/xccdf/models/group.py | Group.as_dict | def as_dict(self):
"""
Serializes the object necessary data in a dictionary.
:returns: Serialized data in a dictionary.
:rtype: dict
"""
result_dict = super(Group, self).as_dict()
statuses = list()
version = None
titles = list()
descript... | python | def as_dict(self):
"""
Serializes the object necessary data in a dictionary.
:returns: Serialized data in a dictionary.
:rtype: dict
"""
result_dict = super(Group, self).as_dict()
statuses = list()
version = None
titles = list()
descript... | [
"def",
"as_dict",
"(",
"self",
")",
":",
"result_dict",
"=",
"super",
"(",
"Group",
",",
"self",
")",
".",
"as_dict",
"(",
")",
"statuses",
"=",
"list",
"(",
")",
"version",
"=",
"None",
"titles",
"=",
"list",
"(",
")",
"descriptions",
"=",
"list",
... | Serializes the object necessary data in a dictionary.
:returns: Serialized data in a dictionary.
:rtype: dict | [
"Serializes",
"the",
"object",
"necessary",
"data",
"in",
"a",
"dictionary",
"."
] | train | https://github.com/rodynnz/xccdf/blob/1b9dc2f06b5cce8db2a54c5f95a8f6bcf5cb6981/src/xccdf/models/group.py#L133-L182 |
alfred82santa/dirty-models | dirty_models/model_types.py | modified_data_decorator | def modified_data_decorator(function):
"""
Decorator to initialise the modified_data if necessary. To be used in list functions
to modify the list
"""
@wraps(function)
def func(self, *args, **kwargs):
"""Decorator function"""
if not self.get_read_only() or not self.is_locked():
... | python | def modified_data_decorator(function):
"""
Decorator to initialise the modified_data if necessary. To be used in list functions
to modify the list
"""
@wraps(function)
def func(self, *args, **kwargs):
"""Decorator function"""
if not self.get_read_only() or not self.is_locked():
... | [
"def",
"modified_data_decorator",
"(",
"function",
")",
":",
"@",
"wraps",
"(",
"function",
")",
"def",
"func",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Decorator function\"\"\"",
"if",
"not",
"self",
".",
"get_read_only",
"... | Decorator to initialise the modified_data if necessary. To be used in list functions
to modify the list | [
"Decorator",
"to",
"initialise",
"the",
"modified_data",
"if",
"necessary",
".",
"To",
"be",
"used",
"in",
"list",
"functions",
"to",
"modify",
"the",
"list"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L11-L25 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel.initialise_modified_data | def initialise_modified_data(self):
"""
Initialise the modified_data if necessary
"""
if self.__modified_data__ is None:
if self.__original_data__:
self.__modified_data__ = list(self.__original_data__)
else:
self.__modified_data__ =... | python | def initialise_modified_data(self):
"""
Initialise the modified_data if necessary
"""
if self.__modified_data__ is None:
if self.__original_data__:
self.__modified_data__ = list(self.__original_data__)
else:
self.__modified_data__ =... | [
"def",
"initialise_modified_data",
"(",
"self",
")",
":",
"if",
"self",
".",
"__modified_data__",
"is",
"None",
":",
"if",
"self",
".",
"__original_data__",
":",
"self",
".",
"__modified_data__",
"=",
"list",
"(",
"self",
".",
"__original_data__",
")",
"else",... | Initialise the modified_data if necessary | [
"Initialise",
"the",
"modified_data",
"if",
"necessary"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L71-L79 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel.append | def append(self, item):
"""
Appending elements to our list
"""
validated_value = self.get_validated_object(item)
if validated_value is not None:
self.__modified_data__.append(validated_value) | python | def append(self, item):
"""
Appending elements to our list
"""
validated_value = self.get_validated_object(item)
if validated_value is not None:
self.__modified_data__.append(validated_value) | [
"def",
"append",
"(",
"self",
",",
"item",
")",
":",
"validated_value",
"=",
"self",
".",
"get_validated_object",
"(",
"item",
")",
"if",
"validated_value",
"is",
"not",
"None",
":",
"self",
".",
"__modified_data__",
".",
"append",
"(",
"validated_value",
")... | Appending elements to our list | [
"Appending",
"elements",
"to",
"our",
"list"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L126-L132 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel.insert | def insert(self, index, p_object):
"""
Insert an element to a list
"""
validated_value = self.get_validated_object(p_object)
if validated_value is not None:
self.__modified_data__.insert(index, validated_value) | python | def insert(self, index, p_object):
"""
Insert an element to a list
"""
validated_value = self.get_validated_object(p_object)
if validated_value is not None:
self.__modified_data__.insert(index, validated_value) | [
"def",
"insert",
"(",
"self",
",",
"index",
",",
"p_object",
")",
":",
"validated_value",
"=",
"self",
".",
"get_validated_object",
"(",
"p_object",
")",
"if",
"validated_value",
"is",
"not",
"None",
":",
"self",
".",
"__modified_data__",
".",
"insert",
"(",... | Insert an element to a list | [
"Insert",
"an",
"element",
"to",
"a",
"list"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L135-L141 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel.index | def index(self, value):
"""
Gets the index in the list for a value
"""
if self.__modified_data__ is not None:
return self.__modified_data__.index(value)
return self.__original_data__.index(value) | python | def index(self, value):
"""
Gets the index in the list for a value
"""
if self.__modified_data__ is not None:
return self.__modified_data__.index(value)
return self.__original_data__.index(value) | [
"def",
"index",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"__modified_data__",
"is",
"not",
"None",
":",
"return",
"self",
".",
"__modified_data__",
".",
"index",
"(",
"value",
")",
"return",
"self",
".",
"__original_data__",
".",
"index",
... | Gets the index in the list for a value | [
"Gets",
"the",
"index",
"in",
"the",
"list",
"for",
"a",
"value"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L143-L149 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel.count | def count(self, value):
"""
Gives the number of occurrencies of a value in the list
"""
if self.__modified_data__ is not None:
return self.__modified_data__.count(value)
return self.__original_data__.count(value) | python | def count(self, value):
"""
Gives the number of occurrencies of a value in the list
"""
if self.__modified_data__ is not None:
return self.__modified_data__.count(value)
return self.__original_data__.count(value) | [
"def",
"count",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"__modified_data__",
"is",
"not",
"None",
":",
"return",
"self",
".",
"__modified_data__",
".",
"count",
"(",
"value",
")",
"return",
"self",
".",
"__original_data__",
".",
"count",
... | Gives the number of occurrencies of a value in the list | [
"Gives",
"the",
"number",
"of",
"occurrencies",
"of",
"a",
"value",
"in",
"the",
"list"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L187-L193 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel.flat_data | def flat_data(self):
"""
Function to pass our modified values to the original ones
"""
def flat_field(value):
"""
Flat item
"""
try:
value.flat_data()
return value
except AttributeError:
... | python | def flat_data(self):
"""
Function to pass our modified values to the original ones
"""
def flat_field(value):
"""
Flat item
"""
try:
value.flat_data()
return value
except AttributeError:
... | [
"def",
"flat_data",
"(",
"self",
")",
":",
"def",
"flat_field",
"(",
"value",
")",
":",
"\"\"\"\n Flat item\n \"\"\"",
"try",
":",
"value",
".",
"flat_data",
"(",
")",
"return",
"value",
"except",
"AttributeError",
":",
"return",
"value",
"... | Function to pass our modified values to the original ones | [
"Function",
"to",
"pass",
"our",
"modified",
"values",
"to",
"the",
"original",
"ones"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L219-L237 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel.export_data | def export_data(self):
"""
Retrieves the data in a jsoned form
"""
def export_field(value):
"""
Export item
"""
try:
return value.export_data()
except AttributeError:
return value
if sel... | python | def export_data(self):
"""
Retrieves the data in a jsoned form
"""
def export_field(value):
"""
Export item
"""
try:
return value.export_data()
except AttributeError:
return value
if sel... | [
"def",
"export_data",
"(",
"self",
")",
":",
"def",
"export_field",
"(",
"value",
")",
":",
"\"\"\"\n Export item\n \"\"\"",
"try",
":",
"return",
"value",
".",
"export_data",
"(",
")",
"except",
"AttributeError",
":",
"return",
"value",
"if"... | Retrieves the data in a jsoned form | [
"Retrieves",
"the",
"data",
"in",
"a",
"jsoned",
"form"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L239-L255 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel.export_modified_data | def export_modified_data(self):
"""
Retrieves the modified data in a jsoned form
"""
def export_modfield(value, is_modified_seq=True):
"""
Export modified item
"""
try:
return value.export_modified_data()
except... | python | def export_modified_data(self):
"""
Retrieves the modified data in a jsoned form
"""
def export_modfield(value, is_modified_seq=True):
"""
Export modified item
"""
try:
return value.export_modified_data()
except... | [
"def",
"export_modified_data",
"(",
"self",
")",
":",
"def",
"export_modfield",
"(",
"value",
",",
"is_modified_seq",
"=",
"True",
")",
":",
"\"\"\"\n Export modified item\n \"\"\"",
"try",
":",
"return",
"value",
".",
"export_modified_data",
"(",
... | Retrieves the modified data in a jsoned form | [
"Retrieves",
"the",
"modified",
"data",
"in",
"a",
"jsoned",
"form"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L257-L274 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel.export_modifications | def export_modifications(self):
"""
Returns list modifications.
"""
if self.__modified_data__ is not None:
return self.export_data()
result = {}
for key, value in enumerate(self.__original_data__):
try:
if not value.is_modified():... | python | def export_modifications(self):
"""
Returns list modifications.
"""
if self.__modified_data__ is not None:
return self.export_data()
result = {}
for key, value in enumerate(self.__original_data__):
try:
if not value.is_modified():... | [
"def",
"export_modifications",
"(",
"self",
")",
":",
"if",
"self",
".",
"__modified_data__",
"is",
"not",
"None",
":",
"return",
"self",
".",
"export_data",
"(",
")",
"result",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"enumerate",
"(",
"self",
... | Returns list modifications. | [
"Returns",
"list",
"modifications",
"."
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L276-L298 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel.export_original_data | def export_original_data(self):
"""
Retrieves the original_data
"""
def export_field(value):
"""
Export item
"""
try:
return value.export_original_data()
except AttributeError:
return value
... | python | def export_original_data(self):
"""
Retrieves the original_data
"""
def export_field(value):
"""
Export item
"""
try:
return value.export_original_data()
except AttributeError:
return value
... | [
"def",
"export_original_data",
"(",
"self",
")",
":",
"def",
"export_field",
"(",
"value",
")",
":",
"\"\"\"\n Export item\n \"\"\"",
"try",
":",
"return",
"value",
".",
"export_original_data",
"(",
")",
"except",
"AttributeError",
":",
"return",... | Retrieves the original_data | [
"Retrieves",
"the",
"original_data"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L300-L314 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel.import_deleted_fields | def import_deleted_fields(self, data):
"""
Set data fields to deleted
"""
def child_delete_from_str(data_str):
"""
Inner function to set children fields to deleted
"""
parts = data_str.split('.', 1)
if parts[0].isnumeric:
... | python | def import_deleted_fields(self, data):
"""
Set data fields to deleted
"""
def child_delete_from_str(data_str):
"""
Inner function to set children fields to deleted
"""
parts = data_str.split('.', 1)
if parts[0].isnumeric:
... | [
"def",
"import_deleted_fields",
"(",
"self",
",",
"data",
")",
":",
"def",
"child_delete_from_str",
"(",
"data_str",
")",
":",
"\"\"\"\n Inner function to set children fields to deleted\n \"\"\"",
"parts",
"=",
"data_str",
".",
"split",
"(",
"'.'",
"... | Set data fields to deleted | [
"Set",
"data",
"fields",
"to",
"deleted"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L323-L341 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel.export_deleted_fields | def export_deleted_fields(self):
"""
Returns a list with any deleted fields form original data.
In tree models, deleted fields on children will be appended.
"""
result = []
if self.__modified_data__ is not None:
return result
for index, item in enumer... | python | def export_deleted_fields(self):
"""
Returns a list with any deleted fields form original data.
In tree models, deleted fields on children will be appended.
"""
result = []
if self.__modified_data__ is not None:
return result
for index, item in enumer... | [
"def",
"export_deleted_fields",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"if",
"self",
".",
"__modified_data__",
"is",
"not",
"None",
":",
"return",
"result",
"for",
"index",
",",
"item",
"in",
"enumerate",
"(",
"self",
")",
":",
"try",
":",
"de... | Returns a list with any deleted fields form original data.
In tree models, deleted fields on children will be appended. | [
"Returns",
"a",
"list",
"with",
"any",
"deleted",
"fields",
"form",
"original",
"data",
".",
"In",
"tree",
"models",
"deleted",
"fields",
"on",
"children",
"will",
"be",
"appended",
"."
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L343-L358 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel.is_modified | def is_modified(self):
"""
Returns whether list is modified or not
"""
if self.__modified_data__ is not None:
return True
for value in self.__original_data__:
try:
if value.is_modified():
return True
except A... | python | def is_modified(self):
"""
Returns whether list is modified or not
"""
if self.__modified_data__ is not None:
return True
for value in self.__original_data__:
try:
if value.is_modified():
return True
except A... | [
"def",
"is_modified",
"(",
"self",
")",
":",
"if",
"self",
".",
"__modified_data__",
"is",
"not",
"None",
":",
"return",
"True",
"for",
"value",
"in",
"self",
".",
"__original_data__",
":",
"try",
":",
"if",
"value",
".",
"is_modified",
"(",
")",
":",
... | Returns whether list is modified or not | [
"Returns",
"whether",
"list",
"is",
"modified",
"or",
"not"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L360-L373 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel.clear_modified_data | def clear_modified_data(self):
"""
Clears only the modified data
"""
self.__modified_data__ = None
for value in self.__original_data__:
try:
value.clear_modified_data()
except AttributeError:
pass | python | def clear_modified_data(self):
"""
Clears only the modified data
"""
self.__modified_data__ = None
for value in self.__original_data__:
try:
value.clear_modified_data()
except AttributeError:
pass | [
"def",
"clear_modified_data",
"(",
"self",
")",
":",
"self",
".",
"__modified_data__",
"=",
"None",
"for",
"value",
"in",
"self",
".",
"__original_data__",
":",
"try",
":",
"value",
".",
"clear_modified_data",
"(",
")",
"except",
"AttributeError",
":",
"pass"
... | Clears only the modified data | [
"Clears",
"only",
"the",
"modified",
"data"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L375-L385 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel.get_attrs_by_path | def get_attrs_by_path(self, field_path, stop_first=False):
"""
It returns list of values looked up by field path.
Field path is dot-formatted string path: ``parent_field.child_field``.
:param field_path: field path. It allows ``*`` as wildcard.
:type field_path: list or None.
... | python | def get_attrs_by_path(self, field_path, stop_first=False):
"""
It returns list of values looked up by field path.
Field path is dot-formatted string path: ``parent_field.child_field``.
:param field_path: field path. It allows ``*`` as wildcard.
:type field_path: list or None.
... | [
"def",
"get_attrs_by_path",
"(",
"self",
",",
"field_path",
",",
"stop_first",
"=",
"False",
")",
":",
"index_list",
",",
"next_field",
"=",
"self",
".",
"_get_indexes_by_path",
"(",
"field_path",
")",
"values",
"=",
"[",
"]",
"for",
"idx",
"in",
"index_list... | It returns list of values looked up by field path.
Field path is dot-formatted string path: ``parent_field.child_field``.
:param field_path: field path. It allows ``*`` as wildcard.
:type field_path: list or None.
:param stop_first: Stop iteration on first value looked up. Default: Fals... | [
"It",
"returns",
"list",
"of",
"values",
"looked",
"up",
"by",
"field",
"path",
".",
"Field",
"path",
"is",
"dot",
"-",
"formatted",
"string",
"path",
":",
"parent_field",
".",
"child_field",
"."
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L395-L426 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel.delete_attr_by_path | def delete_attr_by_path(self, field):
"""
Function for deleting a field specifying the path in the whole model as described
in :func:`dirty:models.models.BaseModel.perform_function_by_path`
"""
index_list, next_field = self._get_indexes_by_path(field)
if index_list:
... | python | def delete_attr_by_path(self, field):
"""
Function for deleting a field specifying the path in the whole model as described
in :func:`dirty:models.models.BaseModel.perform_function_by_path`
"""
index_list, next_field = self._get_indexes_by_path(field)
if index_list:
... | [
"def",
"delete_attr_by_path",
"(",
"self",
",",
"field",
")",
":",
"index_list",
",",
"next_field",
"=",
"self",
".",
"_get_indexes_by_path",
"(",
"field",
")",
"if",
"index_list",
":",
"for",
"index",
"in",
"reversed",
"(",
"index_list",
")",
":",
"if",
"... | Function for deleting a field specifying the path in the whole model as described
in :func:`dirty:models.models.BaseModel.perform_function_by_path` | [
"Function",
"for",
"deleting",
"a",
"field",
"specifying",
"the",
"path",
"in",
"the",
"whole",
"model",
"as",
"described",
"in",
":",
"func",
":",
"dirty",
":",
"models",
".",
"models",
".",
"BaseModel",
".",
"perform_function_by_path"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L447-L458 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel.reset_attr_by_path | def reset_attr_by_path(self, field):
"""
Function for restoring a field specifying the path in the whole model as described
in :func:`dirty:models.models.BaseModel.perform_function_by_path`
"""
index_list, next_field = self._get_indexes_by_path(field)
if index_list:
... | python | def reset_attr_by_path(self, field):
"""
Function for restoring a field specifying the path in the whole model as described
in :func:`dirty:models.models.BaseModel.perform_function_by_path`
"""
index_list, next_field = self._get_indexes_by_path(field)
if index_list:
... | [
"def",
"reset_attr_by_path",
"(",
"self",
",",
"field",
")",
":",
"index_list",
",",
"next_field",
"=",
"self",
".",
"_get_indexes_by_path",
"(",
"field",
")",
"if",
"index_list",
":",
"if",
"next_field",
":",
"for",
"index",
"in",
"index_list",
":",
"self",... | Function for restoring a field specifying the path in the whole model as described
in :func:`dirty:models.models.BaseModel.perform_function_by_path` | [
"Function",
"for",
"restoring",
"a",
"field",
"specifying",
"the",
"path",
"in",
"the",
"whole",
"model",
"as",
"described",
"in",
":",
"func",
":",
"dirty",
":",
"models",
".",
"models",
".",
"BaseModel",
".",
"perform_function_by_path"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L460-L475 |
alfred82santa/dirty-models | dirty_models/model_types.py | ListModel._get_indexes_by_path | def _get_indexes_by_path(self, field):
"""
Returns a list of indexes by field path.
:param field: Field structure as following:
*.subfield_2 would apply the function to the every subfield_2 of the elements
1.subfield_2 would apply the function to the subfield_2 of the elemen... | python | def _get_indexes_by_path(self, field):
"""
Returns a list of indexes by field path.
:param field: Field structure as following:
*.subfield_2 would apply the function to the every subfield_2 of the elements
1.subfield_2 would apply the function to the subfield_2 of the elemen... | [
"def",
"_get_indexes_by_path",
"(",
"self",
",",
"field",
")",
":",
"try",
":",
"field",
",",
"next_field",
"=",
"field",
".",
"split",
"(",
"'.'",
",",
"1",
")",
"except",
"ValueError",
":",
"next_field",
"=",
"''",
"if",
"field",
"==",
"'*'",
":",
... | Returns a list of indexes by field path.
:param field: Field structure as following:
*.subfield_2 would apply the function to the every subfield_2 of the elements
1.subfield_2 would apply the function to the subfield_2 of the element 1
* would apply the function to every element
... | [
"Returns",
"a",
"list",
"of",
"indexes",
"by",
"field",
"path",
"."
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L477-L503 |
inveniosoftware/invenio-marc21 | examples/app.py | example | def example(index):
"""Index page."""
pid = PersistentIdentifier.query.filter_by(id=index).one()
record = RecordMetadata.query.filter_by(id=pid.object_uuid).first()
return render_template("app/detail.html", record=record.json, pid=pid,
title="Demosite Invenio Org") | python | def example(index):
"""Index page."""
pid = PersistentIdentifier.query.filter_by(id=index).one()
record = RecordMetadata.query.filter_by(id=pid.object_uuid).first()
return render_template("app/detail.html", record=record.json, pid=pid,
title="Demosite Invenio Org") | [
"def",
"example",
"(",
"index",
")",
":",
"pid",
"=",
"PersistentIdentifier",
".",
"query",
".",
"filter_by",
"(",
"id",
"=",
"index",
")",
".",
"one",
"(",
")",
"record",
"=",
"RecordMetadata",
".",
"query",
".",
"filter_by",
"(",
"id",
"=",
"pid",
... | Index page. | [
"Index",
"page",
"."
] | train | https://github.com/inveniosoftware/invenio-marc21/blob/b91347b5b000757b6dc9dc1be88d76ca09611905/examples/app.py#L123-L129 |
sbrisard/rebin | rebin.py | rebin | def rebin(a, factor, func=None):
u"""Aggregate data from the input array ``a`` into rectangular tiles.
The output array results from tiling ``a`` and applying `func` to
each tile. ``factor`` specifies the size of the tiles. More
precisely, the returned array ``out`` is such that::
out[i0, i1, ... | python | def rebin(a, factor, func=None):
u"""Aggregate data from the input array ``a`` into rectangular tiles.
The output array results from tiling ``a`` and applying `func` to
each tile. ``factor`` specifies the size of the tiles. More
precisely, the returned array ``out`` is such that::
out[i0, i1, ... | [
"def",
"rebin",
"(",
"a",
",",
"factor",
",",
"func",
"=",
"None",
")",
":",
"a",
"=",
"np",
".",
"asarray",
"(",
"a",
")",
"dim",
"=",
"a",
".",
"ndim",
"if",
"np",
".",
"isscalar",
"(",
"factor",
")",
":",
"factor",
"=",
"dim",
"*",
"(",
... | u"""Aggregate data from the input array ``a`` into rectangular tiles.
The output array results from tiling ``a`` and applying `func` to
each tile. ``factor`` specifies the size of the tiles. More
precisely, the returned array ``out`` is such that::
out[i0, i1, ...] = func(a[f0*i0:f0*(i0+1), f1*i1:... | [
"u",
"Aggregate",
"data",
"from",
"the",
"input",
"array",
"a",
"into",
"rectangular",
"tiles",
"."
] | train | https://github.com/sbrisard/rebin/blob/a0abc9b6e6f82f3c80fe30129f139f1d54f78471/rebin.py#L88-L146 |
alfred82santa/dirty-models | dirty_models/fields.py | can_use_enum | def can_use_enum(func):
"""
Decorator to use Enum value on type checks.
"""
@wraps(func)
def inner(self, value):
if isinstance(value, Enum):
return self.check_value(value.value) or func(self, value.value)
return func(self, value)
return inner | python | def can_use_enum(func):
"""
Decorator to use Enum value on type checks.
"""
@wraps(func)
def inner(self, value):
if isinstance(value, Enum):
return self.check_value(value.value) or func(self, value.value)
return func(self, value)
return inner | [
"def",
"can_use_enum",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"inner",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Enum",
")",
":",
"return",
"self",
".",
"check_value",
"(",
"value",
".",
"va... | Decorator to use Enum value on type checks. | [
"Decorator",
"to",
"use",
"Enum",
"value",
"on",
"type",
"checks",
"."
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/fields.py#L123-L135 |
alfred82santa/dirty-models | dirty_models/fields.py | convert_enum | def convert_enum(func):
"""
Decorator to use Enum value on type casts.
"""
@wraps(func)
def inner(self, value):
try:
if self.check_value(value.value):
return value.value
return func(self, value.value)
except AttributeError:
pass
... | python | def convert_enum(func):
"""
Decorator to use Enum value on type casts.
"""
@wraps(func)
def inner(self, value):
try:
if self.check_value(value.value):
return value.value
return func(self, value.value)
except AttributeError:
pass
... | [
"def",
"convert_enum",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"inner",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"if",
"self",
".",
"check_value",
"(",
"value",
".",
"value",
")",
":",
"return",
"value",
".",
"value",
... | Decorator to use Enum value on type casts. | [
"Decorator",
"to",
"use",
"Enum",
"value",
"on",
"type",
"casts",
"."
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/fields.py#L138-L154 |
alfred82santa/dirty-models | dirty_models/fields.py | BaseField.use_value | def use_value(self, value):
"""Converts value to field type or use original"""
if self.check_value(value):
return value
return self.convert_value(value) | python | def use_value(self, value):
"""Converts value to field type or use original"""
if self.check_value(value):
return value
return self.convert_value(value) | [
"def",
"use_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"check_value",
"(",
"value",
")",
":",
"return",
"value",
"return",
"self",
".",
"convert_value",
"(",
"value",
")"
] | Converts value to field type or use original | [
"Converts",
"value",
"to",
"field",
"type",
"or",
"use",
"original"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/fields.py#L54-L58 |
alfred82santa/dirty-models | dirty_models/fields.py | StringIdField.set_value | def set_value(self, obj, value):
"""Sets value to model if not empty"""
if value:
obj.set_field_value(self.name, value)
else:
self.delete_value(obj) | python | def set_value(self, obj, value):
"""Sets value to model if not empty"""
if value:
obj.set_field_value(self.name, value)
else:
self.delete_value(obj) | [
"def",
"set_value",
"(",
"self",
",",
"obj",
",",
"value",
")",
":",
"if",
"value",
":",
"obj",
".",
"set_field_value",
"(",
"self",
".",
"name",
",",
"value",
")",
"else",
":",
"self",
".",
"delete_value",
"(",
"obj",
")"
] | Sets value to model if not empty | [
"Sets",
"value",
"to",
"model",
"if",
"not",
"empty"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/fields.py#L291-L296 |
alfred82santa/dirty-models | dirty_models/fields.py | DateTimeBaseField.get_parsed_value | def get_parsed_value(self, value):
"""
Helper to cast string to datetime using :member:`parse_format`.
:param value: String representing a datetime
:type value: str
:return: datetime
"""
def get_parser(parser_desc):
try:
return parser... | python | def get_parsed_value(self, value):
"""
Helper to cast string to datetime using :member:`parse_format`.
:param value: String representing a datetime
:type value: str
:return: datetime
"""
def get_parser(parser_desc):
try:
return parser... | [
"def",
"get_parsed_value",
"(",
"self",
",",
"value",
")",
":",
"def",
"get_parser",
"(",
"parser_desc",
")",
":",
"try",
":",
"return",
"parser_desc",
"[",
"'parser'",
"]",
"except",
"TypeError",
":",
"try",
":",
"return",
"get_parser",
"(",
"self",
".",
... | Helper to cast string to datetime using :member:`parse_format`.
:param value: String representing a datetime
:type value: str
:return: datetime | [
"Helper",
"to",
"cast",
"string",
"to",
"datetime",
"using",
":",
"member",
":",
"parse_format",
"."
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/fields.py#L323-L353 |
alfred82santa/dirty-models | dirty_models/fields.py | DateTimeBaseField.get_formatted_value | def get_formatted_value(self, value):
"""
Returns a string from datetime using :member:`parse_format`.
:param value: Datetime to cast to string
:type value: datetime
:return: str
"""
def get_formatter(parser_desc):
try:
return parser_... | python | def get_formatted_value(self, value):
"""
Returns a string from datetime using :member:`parse_format`.
:param value: Datetime to cast to string
:type value: datetime
:return: str
"""
def get_formatter(parser_desc):
try:
return parser_... | [
"def",
"get_formatted_value",
"(",
"self",
",",
"value",
")",
":",
"def",
"get_formatter",
"(",
"parser_desc",
")",
":",
"try",
":",
"return",
"parser_desc",
"[",
"'formatter'",
"]",
"except",
"TypeError",
":",
"if",
"isinstance",
"(",
"parser_desc",
",",
"s... | Returns a string from datetime using :member:`parse_format`.
:param value: Datetime to cast to string
:type value: datetime
:return: str | [
"Returns",
"a",
"string",
"from",
"datetime",
"using",
":",
"member",
":",
"parse_format",
"."
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/fields.py#L355-L390 |
plotly/octogrid | octogrid/parser/parser.py | ArgumentParser.action | def action(self):
"""
Invoke functions according to the supplied flags
"""
user = self.args['--user'] if self.args['--user'] else None
reset = True if self.args['--reset'] else False
if self.args['generate']:
generate_network(user, reset)
elif self.a... | python | def action(self):
"""
Invoke functions according to the supplied flags
"""
user = self.args['--user'] if self.args['--user'] else None
reset = True if self.args['--reset'] else False
if self.args['generate']:
generate_network(user, reset)
elif self.a... | [
"def",
"action",
"(",
"self",
")",
":",
"user",
"=",
"self",
".",
"args",
"[",
"'--user'",
"]",
"if",
"self",
".",
"args",
"[",
"'--user'",
"]",
"else",
"None",
"reset",
"=",
"True",
"if",
"self",
".",
"args",
"[",
"'--reset'",
"]",
"else",
"False"... | Invoke functions according to the supplied flags | [
"Invoke",
"functions",
"according",
"to",
"the",
"supplied",
"flags"
] | train | https://github.com/plotly/octogrid/blob/46237a72c79765fe5a48af7065049c692e6457a7/octogrid/parser/parser.py#L17-L28 |
ox-it/django-conneg | django_conneg/decorators.py | renderer | def renderer(format, mimetypes=(), priority=0, name=None, test=None):
"""
Decorates a view method to say that it renders a particular format and mimetypes.
Use as:
@renderer(format="foo")
def render_foo(self, request, context, template_name): ...
or
@renderer(format="foo", mimet... | python | def renderer(format, mimetypes=(), priority=0, name=None, test=None):
"""
Decorates a view method to say that it renders a particular format and mimetypes.
Use as:
@renderer(format="foo")
def render_foo(self, request, context, template_name): ...
or
@renderer(format="foo", mimet... | [
"def",
"renderer",
"(",
"format",
",",
"mimetypes",
"=",
"(",
")",
",",
"priority",
"=",
"0",
",",
"name",
"=",
"None",
",",
"test",
"=",
"None",
")",
":",
"def",
"g",
"(",
"f",
")",
":",
"return",
"Renderer",
"(",
"f",
",",
"format",
",",
"mim... | Decorates a view method to say that it renders a particular format and mimetypes.
Use as:
@renderer(format="foo")
def render_foo(self, request, context, template_name): ...
or
@renderer(format="foo", mimetypes=("application/x-foo",))
def render_foo(self, request, context, templa... | [
"Decorates",
"a",
"view",
"method",
"to",
"say",
"that",
"it",
"renders",
"a",
"particular",
"format",
"and",
"mimetypes",
"."
] | train | https://github.com/ox-it/django-conneg/blob/4f103932322b3e151fcfdf279f1353dad2049d1f/django_conneg/decorators.py#L3-L23 |
ereOn/azmq | azmq/containers.py | AsyncList.wait_change | async def wait_change(self):
"""
Wait for the list to change.
"""
future = asyncio.Future(loop=self.loop)
self._change_futures.add(future)
future.add_done_callback(self._change_futures.discard)
await future | python | async def wait_change(self):
"""
Wait for the list to change.
"""
future = asyncio.Future(loop=self.loop)
self._change_futures.add(future)
future.add_done_callback(self._change_futures.discard)
await future | [
"async",
"def",
"wait_change",
"(",
"self",
")",
":",
"future",
"=",
"asyncio",
".",
"Future",
"(",
"loop",
"=",
"self",
".",
"loop",
")",
"self",
".",
"_change_futures",
".",
"add",
"(",
"future",
")",
"future",
".",
"add_done_callback",
"(",
"self",
... | Wait for the list to change. | [
"Wait",
"for",
"the",
"list",
"to",
"change",
"."
] | train | https://github.com/ereOn/azmq/blob/9f40d6d721eea7f7659ec6cc668811976db59854/azmq/containers.py#L88-L95 |
ereOn/azmq | azmq/containers.py | FairListProxy.shift | def shift(self, count=1):
"""
Shift the view a specified number of times.
:param count: The count of times to shift the view.
"""
if self:
self._index = (self._index + count) % len(self)
else:
self._index = 0 | python | def shift(self, count=1):
"""
Shift the view a specified number of times.
:param count: The count of times to shift the view.
"""
if self:
self._index = (self._index + count) % len(self)
else:
self._index = 0 | [
"def",
"shift",
"(",
"self",
",",
"count",
"=",
"1",
")",
":",
"if",
"self",
":",
"self",
".",
"_index",
"=",
"(",
"self",
".",
"_index",
"+",
"count",
")",
"%",
"len",
"(",
"self",
")",
"else",
":",
"self",
".",
"_index",
"=",
"0"
] | Shift the view a specified number of times.
:param count: The count of times to shift the view. | [
"Shift",
"the",
"view",
"a",
"specified",
"number",
"of",
"times",
"."
] | train | https://github.com/ereOn/azmq/blob/9f40d6d721eea7f7659ec6cc668811976db59854/azmq/containers.py#L128-L137 |
Visgean/urljects | urljects/patterns.py | render | def render(value):
"""
This function finishes the url pattern creation by adding starting
character ^ end possibly by adding end character at the end
:param value: naive URL value
:return: raw string
"""
# Empty urls
if not value: # use case: wild card imports
return r'^$'
... | python | def render(value):
"""
This function finishes the url pattern creation by adding starting
character ^ end possibly by adding end character at the end
:param value: naive URL value
:return: raw string
"""
# Empty urls
if not value: # use case: wild card imports
return r'^$'
... | [
"def",
"render",
"(",
"value",
")",
":",
"# Empty urls",
"if",
"not",
"value",
":",
"# use case: wild card imports",
"return",
"r'^$'",
"if",
"value",
"[",
"0",
"]",
"!=",
"beginning",
":",
"value",
"=",
"beginning",
"+",
"value",
"if",
"value",
"[",
"-",
... | This function finishes the url pattern creation by adding starting
character ^ end possibly by adding end character at the end
:param value: naive URL value
:return: raw string | [
"This",
"function",
"finishes",
"the",
"url",
"pattern",
"creation",
"by",
"adding",
"starting",
"character",
"^",
"end",
"possibly",
"by",
"adding",
"end",
"character",
"at",
"the",
"end"
] | train | https://github.com/Visgean/urljects/blob/29a3ca03f639ea7a9ee2f795ed17941c86b278ba/urljects/patterns.py#L22-L40 |
Visgean/urljects | urljects/patterns.py | URLPattern.add_part | def add_part(self, part):
"""
Function for adding partial pattern to the value
:param part: string or compiled pattern
"""
if isinstance(part, RE_TYPE):
part = part.pattern
# Allow U / spmething syntax
if self == '^$':
return URLPattern(pa... | python | def add_part(self, part):
"""
Function for adding partial pattern to the value
:param part: string or compiled pattern
"""
if isinstance(part, RE_TYPE):
part = part.pattern
# Allow U / spmething syntax
if self == '^$':
return URLPattern(pa... | [
"def",
"add_part",
"(",
"self",
",",
"part",
")",
":",
"if",
"isinstance",
"(",
"part",
",",
"RE_TYPE",
")",
":",
"part",
"=",
"part",
".",
"pattern",
"# Allow U / spmething syntax",
"if",
"self",
"==",
"'^$'",
":",
"return",
"URLPattern",
"(",
"part",
"... | Function for adding partial pattern to the value
:param part: string or compiled pattern | [
"Function",
"for",
"adding",
"partial",
"pattern",
"to",
"the",
"value",
":",
"param",
"part",
":",
"string",
"or",
"compiled",
"pattern"
] | train | https://github.com/Visgean/urljects/blob/29a3ca03f639ea7a9ee2f795ed17941c86b278ba/urljects/patterns.py#L58-L73 |
publysher/rdflib-django | src/rdflib_django/utils.py | get_conjunctive_graph | def get_conjunctive_graph(store_id=None):
"""
Returns an open conjunctive graph.
"""
if not store_id:
store_id = DEFAULT_STORE
store = DjangoStore(DEFAULT_STORE)
graph = ConjunctiveGraph(store=store, identifier=store_id)
if graph.open(None) != VALID_STORE:
raise ValueError("... | python | def get_conjunctive_graph(store_id=None):
"""
Returns an open conjunctive graph.
"""
if not store_id:
store_id = DEFAULT_STORE
store = DjangoStore(DEFAULT_STORE)
graph = ConjunctiveGraph(store=store, identifier=store_id)
if graph.open(None) != VALID_STORE:
raise ValueError("... | [
"def",
"get_conjunctive_graph",
"(",
"store_id",
"=",
"None",
")",
":",
"if",
"not",
"store_id",
":",
"store_id",
"=",
"DEFAULT_STORE",
"store",
"=",
"DjangoStore",
"(",
"DEFAULT_STORE",
")",
"graph",
"=",
"ConjunctiveGraph",
"(",
"store",
"=",
"store",
",",
... | Returns an open conjunctive graph. | [
"Returns",
"an",
"open",
"conjunctive",
"graph",
"."
] | train | https://github.com/publysher/rdflib-django/blob/e26992af75f96ef27a6ceaf820574e3bca645953/src/rdflib_django/utils.py#L10-L21 |
publysher/rdflib-django | src/rdflib_django/utils.py | get_named_graph | def get_named_graph(identifier, store_id=DEFAULT_STORE, create=True):
"""
Returns an open named graph.
"""
if not isinstance(identifier, URIRef):
identifier = URIRef(identifier)
store = DjangoStore(store_id)
graph = Graph(store, identifier=identifier)
if graph.open(None, create=crea... | python | def get_named_graph(identifier, store_id=DEFAULT_STORE, create=True):
"""
Returns an open named graph.
"""
if not isinstance(identifier, URIRef):
identifier = URIRef(identifier)
store = DjangoStore(store_id)
graph = Graph(store, identifier=identifier)
if graph.open(None, create=crea... | [
"def",
"get_named_graph",
"(",
"identifier",
",",
"store_id",
"=",
"DEFAULT_STORE",
",",
"create",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"identifier",
",",
"URIRef",
")",
":",
"identifier",
"=",
"URIRef",
"(",
"identifier",
")",
"store",
"... | Returns an open named graph. | [
"Returns",
"an",
"open",
"named",
"graph",
"."
] | train | https://github.com/publysher/rdflib-django/blob/e26992af75f96ef27a6ceaf820574e3bca645953/src/rdflib_django/utils.py#L24-L35 |
array-split/array_split | setup.py | read_readme | def read_readme():
"""
Reads part of the README.rst for use as long_description in setup().
"""
text = open("README.rst", "rt").read()
text_lines = text.split("\n")
ld_i_beg = 0
while text_lines[ld_i_beg].find("start long description") < 0:
ld_i_beg += 1
ld_i_beg += 1
ld_i_en... | python | def read_readme():
"""
Reads part of the README.rst for use as long_description in setup().
"""
text = open("README.rst", "rt").read()
text_lines = text.split("\n")
ld_i_beg = 0
while text_lines[ld_i_beg].find("start long description") < 0:
ld_i_beg += 1
ld_i_beg += 1
ld_i_en... | [
"def",
"read_readme",
"(",
")",
":",
"text",
"=",
"open",
"(",
"\"README.rst\"",
",",
"\"rt\"",
")",
".",
"read",
"(",
")",
"text_lines",
"=",
"text",
".",
"split",
"(",
"\"\\n\"",
")",
"ld_i_beg",
"=",
"0",
"while",
"text_lines",
"[",
"ld_i_beg",
"]",... | Reads part of the README.rst for use as long_description in setup(). | [
"Reads",
"part",
"of",
"the",
"README",
".",
"rst",
"for",
"use",
"as",
"long_description",
"in",
"setup",
"()",
"."
] | train | https://github.com/array-split/array_split/blob/e07abe3001209394dde809f7e6f505f9f49a1c26/setup.py#L9-L25 |
jgorset/facebook | facebook/user.py | User.work | def work(self):
"""
A list of :class:`Employment` instances describing the user's work history.
Each structure has attributes ``employer``, ``position``, ``started_at`` and ``ended_at``.
``employer`` and ``position`` reference ``Page`` instances, while ``started_at`` and ``ended_at``
... | python | def work(self):
"""
A list of :class:`Employment` instances describing the user's work history.
Each structure has attributes ``employer``, ``position``, ``started_at`` and ``ended_at``.
``employer`` and ``position`` reference ``Page`` instances, while ``started_at`` and ``ended_at``
... | [
"def",
"work",
"(",
"self",
")",
":",
"employments",
"=",
"[",
"]",
"for",
"work",
"in",
"self",
".",
"cache",
"[",
"'work'",
"]",
":",
"employment",
"=",
"Employment",
"(",
"employer",
"=",
"work",
".",
"get",
"(",
"'employer'",
")",
",",
"position"... | A list of :class:`Employment` instances describing the user's work history.
Each structure has attributes ``employer``, ``position``, ``started_at`` and ``ended_at``.
``employer`` and ``position`` reference ``Page`` instances, while ``started_at`` and ``ended_at``
are datetime objects. | [
"A",
"list",
"of",
":",
"class",
":",
"Employment",
"instances",
"describing",
"the",
"user",
"s",
"work",
"history",
"."
] | train | https://github.com/jgorset/facebook/blob/90f035ae1828e4eeb7af428964fedf0ee99ec2ad/facebook/user.py#L85-L106 |
jgorset/facebook | facebook/user.py | User.languages | def languages(self):
"""
A list of strings describing the user's languages.
"""
languages = []
for language in self.cache['languages']:
language = Structure(
id = language['id'],
name = language['name']
)
langu... | python | def languages(self):
"""
A list of strings describing the user's languages.
"""
languages = []
for language in self.cache['languages']:
language = Structure(
id = language['id'],
name = language['name']
)
langu... | [
"def",
"languages",
"(",
"self",
")",
":",
"languages",
"=",
"[",
"]",
"for",
"language",
"in",
"self",
".",
"cache",
"[",
"'languages'",
"]",
":",
"language",
"=",
"Structure",
"(",
"id",
"=",
"language",
"[",
"'id'",
"]",
",",
"name",
"=",
"languag... | A list of strings describing the user's languages. | [
"A",
"list",
"of",
"strings",
"describing",
"the",
"user",
"s",
"languages",
"."
] | train | https://github.com/jgorset/facebook/blob/90f035ae1828e4eeb7af428964fedf0ee99ec2ad/facebook/user.py#L109-L123 |
jgorset/facebook | facebook/user.py | User.interested_in | def interested_in(self):
"""
A list of strings describing the genders the user is interested in.
"""
genders = []
for gender in self.cache['interested_in']:
genders.append(gender)
return genders | python | def interested_in(self):
"""
A list of strings describing the genders the user is interested in.
"""
genders = []
for gender in self.cache['interested_in']:
genders.append(gender)
return genders | [
"def",
"interested_in",
"(",
"self",
")",
":",
"genders",
"=",
"[",
"]",
"for",
"gender",
"in",
"self",
".",
"cache",
"[",
"'interested_in'",
"]",
":",
"genders",
".",
"append",
"(",
"gender",
")",
"return",
"genders"
] | A list of strings describing the genders the user is interested in. | [
"A",
"list",
"of",
"strings",
"describing",
"the",
"genders",
"the",
"user",
"is",
"interested",
"in",
"."
] | train | https://github.com/jgorset/facebook/blob/90f035ae1828e4eeb7af428964fedf0ee99ec2ad/facebook/user.py#L126-L135 |
jgorset/facebook | facebook/user.py | User.education | def education(self):
"""
A list of structures describing the user's education history.
Each structure has attributes ``school``, ``year``, ``concentration`` and ``type``.
``school``, ``year`` reference ``Page`` instances, while ``concentration`` is a list of ``Page``
instances.... | python | def education(self):
"""
A list of structures describing the user's education history.
Each structure has attributes ``school``, ``year``, ``concentration`` and ``type``.
``school``, ``year`` reference ``Page`` instances, while ``concentration`` is a list of ``Page``
instances.... | [
"def",
"education",
"(",
"self",
")",
":",
"educations",
"=",
"[",
"]",
"for",
"education",
"in",
"self",
".",
"cache",
"[",
"'education'",
"]",
":",
"school",
"=",
"Page",
"(",
"*",
"*",
"education",
".",
"get",
"(",
"'school'",
")",
")",
"year",
... | A list of structures describing the user's education history.
Each structure has attributes ``school``, ``year``, ``concentration`` and ``type``.
``school``, ``year`` reference ``Page`` instances, while ``concentration`` is a list of ``Page``
instances. ``type`` is just a string that describes... | [
"A",
"list",
"of",
"structures",
"describing",
"the",
"user",
"s",
"education",
"history",
"."
] | train | https://github.com/jgorset/facebook/blob/90f035ae1828e4eeb7af428964fedf0ee99ec2ad/facebook/user.py#L138-L171 |
jgorset/facebook | facebook/user.py | User.permissions | def permissions(self):
"""
A list of strings describing permissions.
See Facebook's exhaustive `Permissions Reference <http://developers.facebook.com/docs/authentication/permissions/>`_
for a list of available permissions.
"""
response = self.graph.get('%s/permissions' %... | python | def permissions(self):
"""
A list of strings describing permissions.
See Facebook's exhaustive `Permissions Reference <http://developers.facebook.com/docs/authentication/permissions/>`_
for a list of available permissions.
"""
response = self.graph.get('%s/permissions' %... | [
"def",
"permissions",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"graph",
".",
"get",
"(",
"'%s/permissions'",
"%",
"self",
".",
"id",
")",
"permissions",
"=",
"[",
"]",
"for",
"permission",
",",
"state",
"in",
"response",
"[",
"'data'",
"]",... | A list of strings describing permissions.
See Facebook's exhaustive `Permissions Reference <http://developers.facebook.com/docs/authentication/permissions/>`_
for a list of available permissions. | [
"A",
"list",
"of",
"strings",
"describing",
"permissions",
"."
] | train | https://github.com/jgorset/facebook/blob/90f035ae1828e4eeb7af428964fedf0ee99ec2ad/facebook/user.py#L174-L187 |
jgorset/facebook | facebook/user.py | User.accounts | def accounts(self):
"""
A list of structures describing apps and pages owned by this user.
"""
response = self.graph.get('%s/accounts' % self.id)
accounts = []
for item in response['data']:
account = Structure(
page = Page(
... | python | def accounts(self):
"""
A list of structures describing apps and pages owned by this user.
"""
response = self.graph.get('%s/accounts' % self.id)
accounts = []
for item in response['data']:
account = Structure(
page = Page(
... | [
"def",
"accounts",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"graph",
".",
"get",
"(",
"'%s/accounts'",
"%",
"self",
".",
"id",
")",
"accounts",
"=",
"[",
"]",
"for",
"item",
"in",
"response",
"[",
"'data'",
"]",
":",
"account",
"=",
"St... | A list of structures describing apps and pages owned by this user. | [
"A",
"list",
"of",
"structures",
"describing",
"apps",
"and",
"pages",
"owned",
"by",
"this",
"user",
"."
] | train | https://github.com/jgorset/facebook/blob/90f035ae1828e4eeb7af428964fedf0ee99ec2ad/facebook/user.py#L190-L210 |
rodynnz/xccdf | src/xccdf/models/benchmark.py | Benchmark.update_xml_element | def update_xml_element(self):
"""
Updates the XML element contents to matches the instance contents.
:returns: Updated XML element.
:rtype: lxml.etree._Element
"""
if not hasattr(self, 'xml_element'):
self.xml_element = etree.Element(self.name, nsmap=NSMAP)
... | python | def update_xml_element(self):
"""
Updates the XML element contents to matches the instance contents.
:returns: Updated XML element.
:rtype: lxml.etree._Element
"""
if not hasattr(self, 'xml_element'):
self.xml_element = etree.Element(self.name, nsmap=NSMAP)
... | [
"def",
"update_xml_element",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'xml_element'",
")",
":",
"self",
".",
"xml_element",
"=",
"etree",
".",
"Element",
"(",
"self",
".",
"name",
",",
"nsmap",
"=",
"NSMAP",
")",
"self",
".",
... | Updates the XML element contents to matches the instance contents.
:returns: Updated XML element.
:rtype: lxml.etree._Element | [
"Updates",
"the",
"XML",
"element",
"contents",
"to",
"matches",
"the",
"instance",
"contents",
"."
] | train | https://github.com/rodynnz/xccdf/blob/1b9dc2f06b5cce8db2a54c5f95a8f6bcf5cb6981/src/xccdf/models/benchmark.py#L155-L185 |
rodynnz/xccdf | src/xccdf/models/benchmark.py | Benchmark.as_dict | def as_dict(self):
"""
Serializes the object necessary data in a dictionary.
:returns: Serialized data in a dictionary.
:rtype: dict
"""
result_dict = super(Benchmark, self).as_dict()
statuses = list()
titles = list()
descriptions = list()
... | python | def as_dict(self):
"""
Serializes the object necessary data in a dictionary.
:returns: Serialized data in a dictionary.
:rtype: dict
"""
result_dict = super(Benchmark, self).as_dict()
statuses = list()
titles = list()
descriptions = list()
... | [
"def",
"as_dict",
"(",
"self",
")",
":",
"result_dict",
"=",
"super",
"(",
"Benchmark",
",",
"self",
")",
".",
"as_dict",
"(",
")",
"statuses",
"=",
"list",
"(",
")",
"titles",
"=",
"list",
"(",
")",
"descriptions",
"=",
"list",
"(",
")",
"front_matt... | Serializes the object necessary data in a dictionary.
:returns: Serialized data in a dictionary.
:rtype: dict | [
"Serializes",
"the",
"object",
"necessary",
"data",
"in",
"a",
"dictionary",
"."
] | train | https://github.com/rodynnz/xccdf/blob/1b9dc2f06b5cce8db2a54c5f95a8f6bcf5cb6981/src/xccdf/models/benchmark.py#L187-L246 |
attakei/errcron | errcron/action.py | post_message | def post_message(plugin, polled_time, identity, message):
"""Post single message
:type plugin: errbot.BotPlugin
:type polled_time: datetime.datetime
:type identity: str
:type message: str
"""
user = plugin.build_identifier(identity)
return plugin.send(user, message) | python | def post_message(plugin, polled_time, identity, message):
"""Post single message
:type plugin: errbot.BotPlugin
:type polled_time: datetime.datetime
:type identity: str
:type message: str
"""
user = plugin.build_identifier(identity)
return plugin.send(user, message) | [
"def",
"post_message",
"(",
"plugin",
",",
"polled_time",
",",
"identity",
",",
"message",
")",
":",
"user",
"=",
"plugin",
".",
"build_identifier",
"(",
"identity",
")",
"return",
"plugin",
".",
"send",
"(",
"user",
",",
"message",
")"
] | Post single message
:type plugin: errbot.BotPlugin
:type polled_time: datetime.datetime
:type identity: str
:type message: str | [
"Post",
"single",
"message"
] | train | https://github.com/attakei/errcron/blob/a3938fc7d051daefb6813588fcbeb9592bd00c9a/errcron/action.py#L6-L15 |
ereOn/azmq | azmq/engines/win32.py | start_pipe_server | async def start_pipe_server(
client_connected_cb,
*,
path,
loop=None,
limit=DEFAULT_LIMIT
):
"""
Start listening for connection using Windows named pipes.
"""
path = path.replace('/', '\\')
loop = loop or asyncio.get_event_loop()
def factory():
reader = asyncio.Strea... | python | async def start_pipe_server(
client_connected_cb,
*,
path,
loop=None,
limit=DEFAULT_LIMIT
):
"""
Start listening for connection using Windows named pipes.
"""
path = path.replace('/', '\\')
loop = loop or asyncio.get_event_loop()
def factory():
reader = asyncio.Strea... | [
"async",
"def",
"start_pipe_server",
"(",
"client_connected_cb",
",",
"*",
",",
"path",
",",
"loop",
"=",
"None",
",",
"limit",
"=",
"DEFAULT_LIMIT",
")",
":",
"path",
"=",
"path",
".",
"replace",
"(",
"'/'",
",",
"'\\\\'",
")",
"loop",
"=",
"loop",
"o... | Start listening for connection using Windows named pipes. | [
"Start",
"listening",
"for",
"connection",
"using",
"Windows",
"named",
"pipes",
"."
] | train | https://github.com/ereOn/azmq/blob/9f40d6d721eea7f7659ec6cc668811976db59854/azmq/engines/win32.py#L11-L48 |
ereOn/azmq | azmq/engines/win32.py | open_pipe_connection | async def open_pipe_connection(
path=None,
*,
loop=None,
limit=DEFAULT_LIMIT,
**kwargs
):
"""
Connect to a server using a Windows named pipe.
"""
path = path.replace('/', '\\')
loop = loop or asyncio.get_event_loop()
reader = asyncio.StreamReader(limit=limit, loop=loop)
... | python | async def open_pipe_connection(
path=None,
*,
loop=None,
limit=DEFAULT_LIMIT,
**kwargs
):
"""
Connect to a server using a Windows named pipe.
"""
path = path.replace('/', '\\')
loop = loop or asyncio.get_event_loop()
reader = asyncio.StreamReader(limit=limit, loop=loop)
... | [
"async",
"def",
"open_pipe_connection",
"(",
"path",
"=",
"None",
",",
"*",
",",
"loop",
"=",
"None",
",",
"limit",
"=",
"DEFAULT_LIMIT",
",",
"*",
"*",
"kwargs",
")",
":",
"path",
"=",
"path",
".",
"replace",
"(",
"'/'",
",",
"'\\\\'",
")",
"loop",
... | Connect to a server using a Windows named pipe. | [
"Connect",
"to",
"a",
"server",
"using",
"a",
"Windows",
"named",
"pipe",
"."
] | train | https://github.com/ereOn/azmq/blob/9f40d6d721eea7f7659ec6cc668811976db59854/azmq/engines/win32.py#L51-L73 |
alfred82santa/dirty-models | dirty_models/base.py | BaseData.set_read_only | def set_read_only(self, value):
"""
Sets whether model could be modified or not
"""
if self.__read_only__ != value:
self.__read_only__ = value
self._update_read_only() | python | def set_read_only(self, value):
"""
Sets whether model could be modified or not
"""
if self.__read_only__ != value:
self.__read_only__ = value
self._update_read_only() | [
"def",
"set_read_only",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"__read_only__",
"!=",
"value",
":",
"self",
".",
"__read_only__",
"=",
"value",
"self",
".",
"_update_read_only",
"(",
")"
] | Sets whether model could be modified or not | [
"Sets",
"whether",
"model",
"could",
"be",
"modified",
"or",
"not"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/base.py#L29-L35 |
alfred82santa/dirty-models | dirty_models/base.py | BaseData.is_locked | def is_locked(self):
"""
Returns whether model is locked
"""
if not self.__locked__:
return False
elif self.get_parent():
return self.get_parent().is_locked()
return True | python | def is_locked(self):
"""
Returns whether model is locked
"""
if not self.__locked__:
return False
elif self.get_parent():
return self.get_parent().is_locked()
return True | [
"def",
"is_locked",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"__locked__",
":",
"return",
"False",
"elif",
"self",
".",
"get_parent",
"(",
")",
":",
"return",
"self",
".",
"get_parent",
"(",
")",
".",
"is_locked",
"(",
")",
"return",
"True"
] | Returns whether model is locked | [
"Returns",
"whether",
"model",
"is",
"locked"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/base.py#L61-L70 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.