repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
mikicz/arca | arca/_arca.py | Arca.repo_id | def repo_id(self, repo: str) -> str:
""" Returns an unique identifier from a repo URL for the folder the repo is gonna be pulled in.
"""
if repo.startswith("http"):
repo_id = re.sub(r"https?://(.www)?", "", repo)
repo_id = re.sub(r"\.git/?$", "", repo_id)
else:
... | python | def repo_id(self, repo: str) -> str:
""" Returns an unique identifier from a repo URL for the folder the repo is gonna be pulled in.
"""
if repo.startswith("http"):
repo_id = re.sub(r"https?://(.www)?", "", repo)
repo_id = re.sub(r"\.git/?$", "", repo_id)
else:
... | [
"def",
"repo_id",
"(",
"self",
",",
"repo",
":",
"str",
")",
"->",
"str",
":",
"if",
"repo",
".",
"startswith",
"(",
"\"http\"",
")",
":",
"repo_id",
"=",
"re",
".",
"sub",
"(",
"r\"https?://(.www)?\"",
",",
"\"\"",
",",
"repo",
")",
"repo_id",
"=",
... | Returns an unique identifier from a repo URL for the folder the repo is gonna be pulled in. | [
"Returns",
"an",
"unique",
"identifier",
"from",
"a",
"repo",
"URL",
"for",
"the",
"folder",
"the",
"repo",
"is",
"gonna",
"be",
"pulled",
"in",
"."
] | train | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L145-L163 |
mikicz/arca | arca/_arca.py | Arca.get_path_to_repo | def get_path_to_repo(self, repo: str) -> Path:
""" Returns a :class:`Path <pathlib.Path>` to the location where all the branches from this repo are stored.
:param repo: Repo URL
:return: Path to where branches from this repository are cloned.
"""
return Path(self.base_dir) / "re... | python | def get_path_to_repo(self, repo: str) -> Path:
""" Returns a :class:`Path <pathlib.Path>` to the location where all the branches from this repo are stored.
:param repo: Repo URL
:return: Path to where branches from this repository are cloned.
"""
return Path(self.base_dir) / "re... | [
"def",
"get_path_to_repo",
"(",
"self",
",",
"repo",
":",
"str",
")",
"->",
"Path",
":",
"return",
"Path",
"(",
"self",
".",
"base_dir",
")",
"/",
"\"repos\"",
"/",
"self",
".",
"repo_id",
"(",
"repo",
")"
] | Returns a :class:`Path <pathlib.Path>` to the location where all the branches from this repo are stored.
:param repo: Repo URL
:return: Path to where branches from this repository are cloned. | [
"Returns",
"a",
":",
"class",
":",
"Path",
"<pathlib",
".",
"Path",
">",
"to",
"the",
"location",
"where",
"all",
"the",
"branches",
"from",
"this",
"repo",
"are",
"stored",
"."
] | train | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L168-L174 |
mikicz/arca | arca/_arca.py | Arca.get_path_to_repo_and_branch | def get_path_to_repo_and_branch(self, repo: str, branch: str) -> Path:
""" Returns a :class:`Path <pathlib.Path>` to where this specific branch is stored on disk.
:param repo: Repo URL
:param branch: branch
:return: Path to where the specific branch from this repo is being cloned.
... | python | def get_path_to_repo_and_branch(self, repo: str, branch: str) -> Path:
""" Returns a :class:`Path <pathlib.Path>` to where this specific branch is stored on disk.
:param repo: Repo URL
:param branch: branch
:return: Path to where the specific branch from this repo is being cloned.
... | [
"def",
"get_path_to_repo_and_branch",
"(",
"self",
",",
"repo",
":",
"str",
",",
"branch",
":",
"str",
")",
"->",
"Path",
":",
"return",
"self",
".",
"get_path_to_repo",
"(",
"repo",
")",
".",
"resolve",
"(",
")",
"/",
"branch"
] | Returns a :class:`Path <pathlib.Path>` to where this specific branch is stored on disk.
:param repo: Repo URL
:param branch: branch
:return: Path to where the specific branch from this repo is being cloned. | [
"Returns",
"a",
":",
"class",
":",
"Path",
"<pathlib",
".",
"Path",
">",
"to",
"where",
"this",
"specific",
"branch",
"is",
"stored",
"on",
"disk",
"."
] | train | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L176-L183 |
mikicz/arca | arca/_arca.py | Arca.save_hash | def save_hash(self, repo: str, branch: str, git_repo: Repo):
"""
If ``single_pull`` is enabled, saves the current git hash of the specified repository/branch combination,
to indicate that it shouldn't be pull again.
"""
if self.single_pull:
repo_id = self.repo_id(repo... | python | def save_hash(self, repo: str, branch: str, git_repo: Repo):
"""
If ``single_pull`` is enabled, saves the current git hash of the specified repository/branch combination,
to indicate that it shouldn't be pull again.
"""
if self.single_pull:
repo_id = self.repo_id(repo... | [
"def",
"save_hash",
"(",
"self",
",",
"repo",
":",
"str",
",",
"branch",
":",
"str",
",",
"git_repo",
":",
"Repo",
")",
":",
"if",
"self",
".",
"single_pull",
":",
"repo_id",
"=",
"self",
".",
"repo_id",
"(",
"repo",
")",
"self",
".",
"_current_hashe... | If ``single_pull`` is enabled, saves the current git hash of the specified repository/branch combination,
to indicate that it shouldn't be pull again. | [
"If",
"single_pull",
"is",
"enabled",
"saves",
"the",
"current",
"git",
"hash",
"of",
"the",
"specified",
"repository",
"/",
"branch",
"combination",
"to",
"indicate",
"that",
"it",
"shouldn",
"t",
"be",
"pull",
"again",
"."
] | train | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L185-L192 |
mikicz/arca | arca/_arca.py | Arca.current_git_hash | def current_git_hash(self, repo: str, branch: str, git_repo: Repo, short: bool=False) -> str:
"""
:param repo: Repo URL
:param branch: Branch name
:param git_repo: :class:`Repo <git.repo.base.Repo>` instance.
:param short: Should the short version be returned?
:return: Co... | python | def current_git_hash(self, repo: str, branch: str, git_repo: Repo, short: bool=False) -> str:
"""
:param repo: Repo URL
:param branch: Branch name
:param git_repo: :class:`Repo <git.repo.base.Repo>` instance.
:param short: Should the short version be returned?
:return: Co... | [
"def",
"current_git_hash",
"(",
"self",
",",
"repo",
":",
"str",
",",
"branch",
":",
"str",
",",
"git_repo",
":",
"Repo",
",",
"short",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"current_hash",
"=",
"self",
".",
"_current_hashes",
"[",
"self",
... | :param repo: Repo URL
:param branch: Branch name
:param git_repo: :class:`Repo <git.repo.base.Repo>` instance.
:param short: Should the short version be returned?
:return: Commit hash of the currently pulled version for the specified repo/branch | [
":",
"param",
"repo",
":",
"Repo",
"URL",
":",
"param",
"branch",
":",
"Branch",
"name",
":",
"param",
"git_repo",
":",
":",
"class",
":",
"Repo",
"<git",
".",
"repo",
".",
"base",
".",
"Repo",
">",
"instance",
".",
":",
"param",
"short",
":",
"Sho... | train | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L194-L208 |
mikicz/arca | arca/_arca.py | Arca.pull_again | def pull_again(self, repo: Optional[str]=None, branch: Optional[str]=None) -> None:
""" When ``single_pull`` is enables, tells Arca to pull again.
If ``repo`` and ``branch`` are not specified, pull again everything.
:param repo: (Optional) Pull again all branches from a specified repository.
... | python | def pull_again(self, repo: Optional[str]=None, branch: Optional[str]=None) -> None:
""" When ``single_pull`` is enables, tells Arca to pull again.
If ``repo`` and ``branch`` are not specified, pull again everything.
:param repo: (Optional) Pull again all branches from a specified repository.
... | [
"def",
"pull_again",
"(",
"self",
",",
"repo",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"branch",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"None",
":",
"if",
"repo",
"is",
"None",
"and",
"branch",
"is",
"None",
":",
"s... | When ``single_pull`` is enables, tells Arca to pull again.
If ``repo`` and ``branch`` are not specified, pull again everything.
:param repo: (Optional) Pull again all branches from a specified repository.
:param branch: (Optional) When ``repo`` is specified, pull again only this branch from th... | [
"When",
"single_pull",
"is",
"enables",
"tells",
"Arca",
"to",
"pull",
"again",
"."
] | train | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L210-L231 |
mikicz/arca | arca/_arca.py | Arca.get_reference_repository | def get_reference_repository(self, reference: Optional[Path], repo: str) -> Optional[Path]:
"""
Returns a repository to use in clone command, if there is one to be referenced.
Either provided by the user of generated from already cloned branches (master is preferred).
:param reference: ... | python | def get_reference_repository(self, reference: Optional[Path], repo: str) -> Optional[Path]:
"""
Returns a repository to use in clone command, if there is one to be referenced.
Either provided by the user of generated from already cloned branches (master is preferred).
:param reference: ... | [
"def",
"get_reference_repository",
"(",
"self",
",",
"reference",
":",
"Optional",
"[",
"Path",
"]",
",",
"repo",
":",
"str",
")",
"->",
"Optional",
"[",
"Path",
"]",
":",
"if",
"reference",
"is",
"not",
"None",
":",
"return",
"reference",
".",
"absolute... | Returns a repository to use in clone command, if there is one to be referenced.
Either provided by the user of generated from already cloned branches (master is preferred).
:param reference: Path to a local repository provided by the user or None.
:param repo: Reference for which remote reposit... | [
"Returns",
"a",
"repository",
"to",
"use",
"in",
"clone",
"command",
"if",
"there",
"is",
"one",
"to",
"be",
"referenced",
".",
"Either",
"provided",
"by",
"the",
"user",
"of",
"generated",
"from",
"already",
"cloned",
"branches",
"(",
"master",
"is",
"pre... | train | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L233-L260 |
mikicz/arca | arca/_arca.py | Arca._pull | def _pull(self, *, repo_path: Path=None, git_repo: Repo=None, repo: str=None, branch: str=None,
depth: Optional[int]=None,
reference: Optional[Path]=None
) -> Repo:
"""
Returns a :class:`Repo <git.repo.base.Repo>` instance, either pulls existing or
clone... | python | def _pull(self, *, repo_path: Path=None, git_repo: Repo=None, repo: str=None, branch: str=None,
depth: Optional[int]=None,
reference: Optional[Path]=None
) -> Repo:
"""
Returns a :class:`Repo <git.repo.base.Repo>` instance, either pulls existing or
clone... | [
"def",
"_pull",
"(",
"self",
",",
"*",
",",
"repo_path",
":",
"Path",
"=",
"None",
",",
"git_repo",
":",
"Repo",
"=",
"None",
",",
"repo",
":",
"str",
"=",
"None",
",",
"branch",
":",
"str",
"=",
"None",
",",
"depth",
":",
"Optional",
"[",
"int",... | Returns a :class:`Repo <git.repo.base.Repo>` instance, either pulls existing or
clones a new copy. | [
"Returns",
"a",
":",
"class",
":",
"Repo",
"<git",
".",
"repo",
".",
"base",
".",
"Repo",
">",
"instance",
"either",
"pulls",
"existing",
"or",
"clones",
"a",
"new",
"copy",
"."
] | train | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L262-L293 |
mikicz/arca | arca/_arca.py | Arca.get_files | def get_files(self, repo: str, branch: str, *,
depth: Optional[int]=1,
reference: Optional[Path]=None
) -> Tuple[Repo, Path]:
"""
Either clones the repository if it's not cloned already or pulls from origin.
If ``single_pull`` is enabled, onl... | python | def get_files(self, repo: str, branch: str, *,
depth: Optional[int]=1,
reference: Optional[Path]=None
) -> Tuple[Repo, Path]:
"""
Either clones the repository if it's not cloned already or pulls from origin.
If ``single_pull`` is enabled, onl... | [
"def",
"get_files",
"(",
"self",
",",
"repo",
":",
"str",
",",
"branch",
":",
"str",
",",
"*",
",",
"depth",
":",
"Optional",
"[",
"int",
"]",
"=",
"1",
",",
"reference",
":",
"Optional",
"[",
"Path",
"]",
"=",
"None",
")",
"->",
"Tuple",
"[",
... | Either clones the repository if it's not cloned already or pulls from origin.
If ``single_pull`` is enabled, only pulls if the repo/branch combination wasn't pulled again by this instance.
:param repo: Repo URL
:param branch: Branch name
:param depth: See :meth:`run`
:param ref... | [
"Either",
"clones",
"the",
"repository",
"if",
"it",
"s",
"not",
"cloned",
"already",
"or",
"pulls",
"from",
"origin",
".",
"If",
"single_pull",
"is",
"enabled",
"only",
"pulls",
"if",
"the",
"repo",
"/",
"branch",
"combination",
"wasn",
"t",
"pulled",
"ag... | train | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L295-L332 |
mikicz/arca | arca/_arca.py | Arca.get_repo | def get_repo(self, repo: str, branch: str, *,
depth: Optional[int]=1,
reference: Optional[Path]=None
) -> Repo:
""" Returns a :class:`Repo <git.repo.base.Repo>` instance for the branch.
See :meth:`run` for arguments descriptions.
"""
gi... | python | def get_repo(self, repo: str, branch: str, *,
depth: Optional[int]=1,
reference: Optional[Path]=None
) -> Repo:
""" Returns a :class:`Repo <git.repo.base.Repo>` instance for the branch.
See :meth:`run` for arguments descriptions.
"""
gi... | [
"def",
"get_repo",
"(",
"self",
",",
"repo",
":",
"str",
",",
"branch",
":",
"str",
",",
"*",
",",
"depth",
":",
"Optional",
"[",
"int",
"]",
"=",
"1",
",",
"reference",
":",
"Optional",
"[",
"Path",
"]",
"=",
"None",
")",
"->",
"Repo",
":",
"g... | Returns a :class:`Repo <git.repo.base.Repo>` instance for the branch.
See :meth:`run` for arguments descriptions. | [
"Returns",
"a",
":",
"class",
":",
"Repo",
"<git",
".",
"repo",
".",
"base",
".",
"Repo",
">",
"instance",
"for",
"the",
"branch",
"."
] | train | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L334-L344 |
mikicz/arca | arca/_arca.py | Arca.cache_key | def cache_key(self, repo: str, branch: str, task: Task, git_repo: Repo) -> str:
""" Returns the key used for storing results in cache.
"""
return "{repo}_{branch}_{hash}_{task}".format(repo=self.repo_id(repo),
branch=branch,
... | python | def cache_key(self, repo: str, branch: str, task: Task, git_repo: Repo) -> str:
""" Returns the key used for storing results in cache.
"""
return "{repo}_{branch}_{hash}_{task}".format(repo=self.repo_id(repo),
branch=branch,
... | [
"def",
"cache_key",
"(",
"self",
",",
"repo",
":",
"str",
",",
"branch",
":",
"str",
",",
"task",
":",
"Task",
",",
"git_repo",
":",
"Repo",
")",
"->",
"str",
":",
"return",
"\"{repo}_{branch}_{hash}_{task}\"",
".",
"format",
"(",
"repo",
"=",
"self",
... | Returns the key used for storing results in cache. | [
"Returns",
"the",
"key",
"used",
"for",
"storing",
"results",
"in",
"cache",
"."
] | train | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L346-L352 |
mikicz/arca | arca/_arca.py | Arca.run | def run(self, repo: str, branch: str, task: Task, *,
depth: DepthDefinitionType=1,
reference: ReferenceDefinitionType=None
) -> Result:
""" Runs the ``task`` using the configured backend.
:param repo: Target git repository
:param branch: Target git branch
... | python | def run(self, repo: str, branch: str, task: Task, *,
depth: DepthDefinitionType=1,
reference: ReferenceDefinitionType=None
) -> Result:
""" Runs the ``task`` using the configured backend.
:param repo: Target git repository
:param branch: Target git branch
... | [
"def",
"run",
"(",
"self",
",",
"repo",
":",
"str",
",",
"branch",
":",
"str",
",",
"task",
":",
"Task",
",",
"*",
",",
"depth",
":",
"DepthDefinitionType",
"=",
"1",
",",
"reference",
":",
"ReferenceDefinitionType",
"=",
"None",
")",
"->",
"Result",
... | Runs the ``task`` using the configured backend.
:param repo: Target git repository
:param branch: Target git branch
:param task: Task which will be run in the target repository
:param depth: How many commits back should the repo be cloned in case the target repository isn't cloned yet.
... | [
"Runs",
"the",
"task",
"using",
"the",
"configured",
"backend",
"."
] | train | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L354-L393 |
mikicz/arca | arca/_arca.py | Arca.static_filename | def static_filename(self, repo: str, branch: str, relative_path: Union[str, Path], *,
depth: DepthDefinitionType=1,
reference: ReferenceDefinitionType=None
) -> Path:
"""
Returns an absolute path to where a file from the repo was cl... | python | def static_filename(self, repo: str, branch: str, relative_path: Union[str, Path], *,
depth: DepthDefinitionType=1,
reference: ReferenceDefinitionType=None
) -> Path:
"""
Returns an absolute path to where a file from the repo was cl... | [
"def",
"static_filename",
"(",
"self",
",",
"repo",
":",
"str",
",",
"branch",
":",
"str",
",",
"relative_path",
":",
"Union",
"[",
"str",
",",
"Path",
"]",
",",
"*",
",",
"depth",
":",
"DepthDefinitionType",
"=",
"1",
",",
"reference",
":",
"Reference... | Returns an absolute path to where a file from the repo was cloned to.
:param repo: Repo URL
:param branch: Branch name
:param relative_path: Relative path to the requested file
:param depth: See :meth:`run`
:param reference: See :meth:`run`
:return: Absolute path to the... | [
"Returns",
"an",
"absolute",
"path",
"to",
"where",
"a",
"file",
"from",
"the",
"repo",
"was",
"cloned",
"to",
"."
] | train | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L402-L440 |
mikicz/arca | arca/_arca.py | Arca.validate_depth | def validate_depth(self, depth: DepthDefinitionType) -> Optional[int]:
""" Converts the depth to int and validates that the value can be used.
:raise ValueError: If the provided depth is not valid
"""
if depth is not None:
try:
depth = int(depth)
... | python | def validate_depth(self, depth: DepthDefinitionType) -> Optional[int]:
""" Converts the depth to int and validates that the value can be used.
:raise ValueError: If the provided depth is not valid
"""
if depth is not None:
try:
depth = int(depth)
... | [
"def",
"validate_depth",
"(",
"self",
",",
"depth",
":",
"DepthDefinitionType",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"if",
"depth",
"is",
"not",
"None",
":",
"try",
":",
"depth",
"=",
"int",
"(",
"depth",
")",
"except",
"ValueError",
":",
"rais... | Converts the depth to int and validates that the value can be used.
:raise ValueError: If the provided depth is not valid | [
"Converts",
"the",
"depth",
"to",
"int",
"and",
"validates",
"that",
"the",
"value",
"can",
"be",
"used",
"."
] | train | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L442-L457 |
mikicz/arca | arca/_arca.py | Arca.validate_reference | def validate_reference(self, reference: ReferenceDefinitionType) -> Optional[Path]:
""" Converts reference to :class:`Path <pathlib.Path>`
:raise ValueError: If ``reference`` can't be converted to :class:`Path <pathlib.Path>`.
"""
if reference is not None:
if isinstance(refe... | python | def validate_reference(self, reference: ReferenceDefinitionType) -> Optional[Path]:
""" Converts reference to :class:`Path <pathlib.Path>`
:raise ValueError: If ``reference`` can't be converted to :class:`Path <pathlib.Path>`.
"""
if reference is not None:
if isinstance(refe... | [
"def",
"validate_reference",
"(",
"self",
",",
"reference",
":",
"ReferenceDefinitionType",
")",
"->",
"Optional",
"[",
"Path",
"]",
":",
"if",
"reference",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"reference",
",",
"bytes",
")",
":",
"reference",
... | Converts reference to :class:`Path <pathlib.Path>`
:raise ValueError: If ``reference`` can't be converted to :class:`Path <pathlib.Path>`. | [
"Converts",
"reference",
"to",
":",
"class",
":",
"Path",
"<pathlib",
".",
"Path",
">"
] | train | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L459-L472 |
brinkframework/brink | brink/fields.py | Field.validate | def validate(self, data):
"""
Runs all field validators.
"""
for v in self.validators:
v(self, data)
return data | python | def validate(self, data):
"""
Runs all field validators.
"""
for v in self.validators:
v(self, data)
return data | [
"def",
"validate",
"(",
"self",
",",
"data",
")",
":",
"for",
"v",
"in",
"self",
".",
"validators",
":",
"v",
"(",
"self",
",",
"data",
")",
"return",
"data"
] | Runs all field validators. | [
"Runs",
"all",
"field",
"validators",
"."
] | train | https://github.com/brinkframework/brink/blob/e837ee35a57140994b4e761cc756af172e5d5aa1/brink/fields.py#L88-L94 |
6809/dragonlib | dragonlib/dragon32/pygments_lexer.py | list_styles | def list_styles(style_name):
"""
Just list all different styles entries
"""
style = get_style_by_name(style_name)
keys = list(style)[0][1]
Styles = namedtuple("Style", keys)
existing_styles = {}
for ttype, ndef in style:
s = Styles(**ndef)
if s in existing_styles:
... | python | def list_styles(style_name):
"""
Just list all different styles entries
"""
style = get_style_by_name(style_name)
keys = list(style)[0][1]
Styles = namedtuple("Style", keys)
existing_styles = {}
for ttype, ndef in style:
s = Styles(**ndef)
if s in existing_styles:
... | [
"def",
"list_styles",
"(",
"style_name",
")",
":",
"style",
"=",
"get_style_by_name",
"(",
"style_name",
")",
"keys",
"=",
"list",
"(",
"style",
")",
"[",
"0",
"]",
"[",
"1",
"]",
"Styles",
"=",
"namedtuple",
"(",
"\"Style\"",
",",
"keys",
")",
"existi... | Just list all different styles entries | [
"Just",
"list",
"all",
"different",
"styles",
"entries"
] | train | https://github.com/6809/dragonlib/blob/faa4011e76c5857db96efdb4199e2fd49711e999/dragonlib/dragon32/pygments_lexer.py#L87-L108 |
azavea/django-tinsel | django_tinsel/utils.py | decorate | def decorate(*reversed_views):
"""
provide a syntax decorating views without nested calls.
instead of:
json_api_call(etag(<hash_fn>)(<view_fn>)))
you can write:
decorate(json_api_call, etag(<hash_fn>), <view_fn>)
"""
fns = reversed_views[::-1]
view = fns[0]
for wrapper in fns[1... | python | def decorate(*reversed_views):
"""
provide a syntax decorating views without nested calls.
instead of:
json_api_call(etag(<hash_fn>)(<view_fn>)))
you can write:
decorate(json_api_call, etag(<hash_fn>), <view_fn>)
"""
fns = reversed_views[::-1]
view = fns[0]
for wrapper in fns[1... | [
"def",
"decorate",
"(",
"*",
"reversed_views",
")",
":",
"fns",
"=",
"reversed_views",
"[",
":",
":",
"-",
"1",
"]",
"view",
"=",
"fns",
"[",
"0",
"]",
"for",
"wrapper",
"in",
"fns",
"[",
"1",
":",
"]",
":",
"view",
"=",
"wrapper",
"(",
"view",
... | provide a syntax decorating views without nested calls.
instead of:
json_api_call(etag(<hash_fn>)(<view_fn>)))
you can write:
decorate(json_api_call, etag(<hash_fn>), <view_fn>) | [
"provide",
"a",
"syntax",
"decorating",
"views",
"without",
"nested",
"calls",
"."
] | train | https://github.com/azavea/django-tinsel/blob/ef9e70750d98907b8f72248c1ba4c4423f04f60f/django_tinsel/utils.py#L15-L29 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/data/StringValueMap.py | StringValueMap.set_as_object | def set_as_object(self, *args):
"""
Sets a new value to map element specified by its index.
When the index is not defined, it resets the entire map value.
This method has double purpose because method overrides are not supported in JavaScript.
:param args: objects to set
... | python | def set_as_object(self, *args):
"""
Sets a new value to map element specified by its index.
When the index is not defined, it resets the entire map value.
This method has double purpose because method overrides are not supported in JavaScript.
:param args: objects to set
... | [
"def",
"set_as_object",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"self",
".",
"set_as_map",
"(",
"args",
"[",
"0",
"]",
")",
"elif",
"len",
"(",
"args",
")",
"==",
"2",
":",
"self",
".",
"put",
"... | Sets a new value to map element specified by its index.
When the index is not defined, it resets the entire map value.
This method has double purpose because method overrides are not supported in JavaScript.
:param args: objects to set | [
"Sets",
"a",
"new",
"value",
"to",
"map",
"element",
"specified",
"by",
"its",
"index",
".",
"When",
"the",
"index",
"is",
"not",
"defined",
"it",
"resets",
"the",
"entire",
"map",
"value",
".",
"This",
"method",
"has",
"double",
"purpose",
"because",
"m... | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/data/StringValueMap.py#L114-L125 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/data/StringValueMap.py | StringValueMap.get_as_map | def get_as_map(self, key):
"""
Converts map element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible.
:param key: a key of element to get.
:return: AnyValueMap value of the element or empty AnyValueMap if conversion is not supported.
"""
if... | python | def get_as_map(self, key):
"""
Converts map element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible.
:param key: a key of element to get.
:return: AnyValueMap value of the element or empty AnyValueMap if conversion is not supported.
"""
if... | [
"def",
"get_as_map",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"==",
"None",
":",
"map",
"=",
"{",
"}",
"for",
"(",
"k",
",",
"v",
")",
"in",
"self",
".",
"items",
"(",
")",
":",
"map",
"[",
"k",
"]",
"=",
"v",
"return",
"map",
"else"... | Converts map element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible.
:param key: a key of element to get.
:return: AnyValueMap value of the element or empty AnyValueMap if conversion is not supported. | [
"Converts",
"map",
"element",
"into",
"an",
"AnyValueMap",
"or",
"returns",
"empty",
"AnyValueMap",
"if",
"conversion",
"is",
"not",
"possible",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/data/StringValueMap.py#L127-L142 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/data/StringValueMap.py | StringValueMap.from_tuples_array | def from_tuples_array(tuples):
"""
Creates a new StringValueMap from a list of key-value pairs called tuples.
The method is similar to [[fromTuples]] but tuples are passed as array instead of parameters.
:param tuples: a list of values where odd elements are keys and the following even ... | python | def from_tuples_array(tuples):
"""
Creates a new StringValueMap from a list of key-value pairs called tuples.
The method is similar to [[fromTuples]] but tuples are passed as array instead of parameters.
:param tuples: a list of values where odd elements are keys and the following even ... | [
"def",
"from_tuples_array",
"(",
"tuples",
")",
":",
"result",
"=",
"StringValueMap",
"(",
")",
"if",
"tuples",
"==",
"None",
"or",
"len",
"(",
"tuples",
")",
"==",
"0",
":",
"return",
"result",
"index",
"=",
"0",
"while",
"index",
"<",
"len",
"(",
"... | Creates a new StringValueMap from a list of key-value pairs called tuples.
The method is similar to [[fromTuples]] but tuples are passed as array instead of parameters.
:param tuples: a list of values where odd elements are keys and the following even elements are values
:return: a newly creat... | [
"Creates",
"a",
"new",
"StringValueMap",
"from",
"a",
"list",
"of",
"key",
"-",
"value",
"pairs",
"called",
"tuples",
".",
"The",
"method",
"is",
"similar",
"to",
"[[",
"fromTuples",
"]]",
"but",
"tuples",
"are",
"passed",
"as",
"array",
"instead",
"of",
... | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/data/StringValueMap.py#L480-L505 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/data/StringValueMap.py | StringValueMap.from_string | def from_string(line):
"""
Parses semicolon-separated key-value pairs and returns them as a StringValueMap.
:param line: semicolon-separated key-value list to initialize StringValueMap.
:return: a newly created StringValueMap.
"""
result = StringValueMap()
... | python | def from_string(line):
"""
Parses semicolon-separated key-value pairs and returns them as a StringValueMap.
:param line: semicolon-separated key-value list to initialize StringValueMap.
:return: a newly created StringValueMap.
"""
result = StringValueMap()
... | [
"def",
"from_string",
"(",
"line",
")",
":",
"result",
"=",
"StringValueMap",
"(",
")",
"if",
"line",
"==",
"None",
"or",
"len",
"(",
"line",
")",
"==",
"0",
":",
"return",
"result",
"tokens",
"=",
"str",
"(",
"line",
")",
".",
"split",
"(",
"';'",... | Parses semicolon-separated key-value pairs and returns them as a StringValueMap.
:param line: semicolon-separated key-value list to initialize StringValueMap.
:return: a newly created StringValueMap. | [
"Parses",
"semicolon",
"-",
"separated",
"key",
"-",
"value",
"pairs",
"and",
"returns",
"them",
"as",
"a",
"StringValueMap",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/data/StringValueMap.py#L508-L530 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/data/StringValueMap.py | StringValueMap.from_maps | def from_maps(*maps):
"""
Creates a new AnyValueMap by merging two or more maps.
Maps defined later in the list override values from previously defined maps.
:param maps: an array of maps to be merged
:return: a newly created AnyValueMap.
"""
result = StringValu... | python | def from_maps(*maps):
"""
Creates a new AnyValueMap by merging two or more maps.
Maps defined later in the list override values from previously defined maps.
:param maps: an array of maps to be merged
:return: a newly created AnyValueMap.
"""
result = StringValu... | [
"def",
"from_maps",
"(",
"*",
"maps",
")",
":",
"result",
"=",
"StringValueMap",
"(",
")",
"if",
"maps",
"==",
"None",
"or",
"len",
"(",
"maps",
")",
"==",
"0",
":",
"return",
"result",
"for",
"map",
"in",
"maps",
":",
"for",
"(",
"k",
",",
"v",
... | Creates a new AnyValueMap by merging two or more maps.
Maps defined later in the list override values from previously defined maps.
:param maps: an array of maps to be merged
:return: a newly created AnyValueMap. | [
"Creates",
"a",
"new",
"AnyValueMap",
"by",
"merging",
"two",
"or",
"more",
"maps",
".",
"Maps",
"defined",
"later",
"in",
"the",
"list",
"override",
"values",
"from",
"previously",
"defined",
"maps",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/data/StringValueMap.py#L534-L553 |
20c/django-handleref | django_handleref/models.py | HandleRefModel.delete | def delete(self, hard=False):
"""
Override the vanilla delete functionality to soft-delete
instead. Soft-delete is accomplished by setting the
status field to "deleted"
Arguments:
hard <bool=False> if true, do a hard delete instead, effectively
removing the obj... | python | def delete(self, hard=False):
"""
Override the vanilla delete functionality to soft-delete
instead. Soft-delete is accomplished by setting the
status field to "deleted"
Arguments:
hard <bool=False> if true, do a hard delete instead, effectively
removing the obj... | [
"def",
"delete",
"(",
"self",
",",
"hard",
"=",
"False",
")",
":",
"if",
"hard",
":",
"return",
"models",
".",
"Model",
".",
"delete",
"(",
"self",
")",
"self",
".",
"status",
"=",
"\"deleted\"",
"self",
".",
"save",
"(",
")",
"for",
"key",
"in",
... | Override the vanilla delete functionality to soft-delete
instead. Soft-delete is accomplished by setting the
status field to "deleted"
Arguments:
hard <bool=False> if true, do a hard delete instead, effectively
removing the object from the database | [
"Override",
"the",
"vanilla",
"delete",
"functionality",
"to",
"soft",
"-",
"delete",
"instead",
".",
"Soft",
"-",
"delete",
"is",
"accomplished",
"by",
"setting",
"the",
"status",
"field",
"to",
"deleted"
] | train | https://github.com/20c/django-handleref/blob/ff4ca6ad39c68947e8a6d8e478daae4cd43663ca/django_handleref/models.py#L118-L145 |
TrainerDex/TrainerDex.py | trainerdex/client.py | Client.get_trainer_from_username | def get_trainer_from_username(self, username, detail=False):
"""Returns a Trainer object from a Trainers username"""
params = {
'detail': '1' if detail is True else '0',
'q': username
}
r = requests.get(api_url+'trainers/', params=params, headers=self.headers)
print(request_status(r))
try:
r = r.js... | python | def get_trainer_from_username(self, username, detail=False):
"""Returns a Trainer object from a Trainers username"""
params = {
'detail': '1' if detail is True else '0',
'q': username
}
r = requests.get(api_url+'trainers/', params=params, headers=self.headers)
print(request_status(r))
try:
r = r.js... | [
"def",
"get_trainer_from_username",
"(",
"self",
",",
"username",
",",
"detail",
"=",
"False",
")",
":",
"params",
"=",
"{",
"'detail'",
":",
"'1'",
"if",
"detail",
"is",
"True",
"else",
"'0'",
",",
"'q'",
":",
"username",
"}",
"r",
"=",
"requests",
".... | Returns a Trainer object from a Trainers username | [
"Returns",
"a",
"Trainer",
"object",
"from",
"a",
"Trainers",
"username"
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L26-L38 |
TrainerDex/TrainerDex.py | trainerdex/client.py | Client.discord_to_users | def discord_to_users(self, memberlist):
"""
expects a list of discord.py user objects
returns a list of TrainerDex.py user objects
"""
_memberlist = self.get_discord_user(x.id for x in memberlist)
return list(set(x.owner() for x in _memberlist)) | python | def discord_to_users(self, memberlist):
"""
expects a list of discord.py user objects
returns a list of TrainerDex.py user objects
"""
_memberlist = self.get_discord_user(x.id for x in memberlist)
return list(set(x.owner() for x in _memberlist)) | [
"def",
"discord_to_users",
"(",
"self",
",",
"memberlist",
")",
":",
"_memberlist",
"=",
"self",
".",
"get_discord_user",
"(",
"x",
".",
"id",
"for",
"x",
"in",
"memberlist",
")",
"return",
"list",
"(",
"set",
"(",
"x",
".",
"owner",
"(",
")",
"for",
... | expects a list of discord.py user objects
returns a list of TrainerDex.py user objects | [
"expects",
"a",
"list",
"of",
"discord",
".",
"py",
"user",
"objects",
"returns",
"a",
"list",
"of",
"TrainerDex",
".",
"py",
"user",
"objects"
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L40-L46 |
TrainerDex/TrainerDex.py | trainerdex/client.py | Client.create_trainer | def create_trainer(self, username, team, start_date=None, has_cheated=None, last_cheated=None, currently_cheats=None, statistics=True, daily_goal=None, total_goal=None, prefered=True, account=None, verified=False):
"""Add a trainer to the database"""
args = locals()
url = api_url+'trainers/'
payload = {
'use... | python | def create_trainer(self, username, team, start_date=None, has_cheated=None, last_cheated=None, currently_cheats=None, statistics=True, daily_goal=None, total_goal=None, prefered=True, account=None, verified=False):
"""Add a trainer to the database"""
args = locals()
url = api_url+'trainers/'
payload = {
'use... | [
"def",
"create_trainer",
"(",
"self",
",",
"username",
",",
"team",
",",
"start_date",
"=",
"None",
",",
"has_cheated",
"=",
"None",
",",
"last_cheated",
"=",
"None",
",",
"currently_cheats",
"=",
"None",
",",
"statistics",
"=",
"True",
",",
"daily_goal",
... | Add a trainer to the database | [
"Add",
"a",
"trainer",
"to",
"the",
"database"
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L48-L71 |
TrainerDex/TrainerDex.py | trainerdex/client.py | Client.update_trainer | def update_trainer(self, trainer, username=None, start_date=None, has_cheated=None, last_cheated=None, currently_cheats=None, statistics=None, daily_goal=None, total_goal=None, prefered=None):
"""Update parts of a trainer in a database"""
args = locals()
if not isinstance(trainer, Trainer):
raise ValueError
... | python | def update_trainer(self, trainer, username=None, start_date=None, has_cheated=None, last_cheated=None, currently_cheats=None, statistics=None, daily_goal=None, total_goal=None, prefered=None):
"""Update parts of a trainer in a database"""
args = locals()
if not isinstance(trainer, Trainer):
raise ValueError
... | [
"def",
"update_trainer",
"(",
"self",
",",
"trainer",
",",
"username",
"=",
"None",
",",
"start_date",
"=",
"None",
",",
"has_cheated",
"=",
"None",
",",
"last_cheated",
"=",
"None",
",",
"currently_cheats",
"=",
"None",
",",
"statistics",
"=",
"None",
","... | Update parts of a trainer in a database | [
"Update",
"parts",
"of",
"a",
"trainer",
"in",
"a",
"database"
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L73-L92 |
TrainerDex/TrainerDex.py | trainerdex/client.py | Client.create_update | def create_update(self, trainer, xp, time_updated=None):
"""Add a Update object to the database
Arguments:
trainer - expects a int of trainer's id or a trainer object
xp
time_updated - expects datetime.datetime
"""
if isinstance(trainer, Trainer):
trainer = trainer.id
url = api_url+'trainers... | python | def create_update(self, trainer, xp, time_updated=None):
"""Add a Update object to the database
Arguments:
trainer - expects a int of trainer's id or a trainer object
xp
time_updated - expects datetime.datetime
"""
if isinstance(trainer, Trainer):
trainer = trainer.id
url = api_url+'trainers... | [
"def",
"create_update",
"(",
"self",
",",
"trainer",
",",
"xp",
",",
"time_updated",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"trainer",
",",
"Trainer",
")",
":",
"trainer",
"=",
"trainer",
".",
"id",
"url",
"=",
"api_url",
"+",
"'trainers/'",
"... | Add a Update object to the database
Arguments:
trainer - expects a int of trainer's id or a trainer object
xp
time_updated - expects datetime.datetime | [
"Add",
"a",
"Update",
"object",
"to",
"the",
"database",
"Arguments",
":",
"trainer",
"-",
"expects",
"a",
"int",
"of",
"trainer",
"s",
"id",
"or",
"a",
"trainer",
"object",
"xp",
"time_updated",
"-",
"expects",
"datetime",
".",
"datetime"
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L94-L119 |
TrainerDex/TrainerDex.py | trainerdex/client.py | Client.import_discord_user | def import_discord_user(self, uid, user):
"""Add a discord user to the database if not already present, get if is present. """
url = api_url+'users/social/'
payload = {
'user': int(user),
'provider': 'discord',
'uid': str(uid)
}
print(json.dumps(payload))
r = requests.put(url, data=json.dumps(paylo... | python | def import_discord_user(self, uid, user):
"""Add a discord user to the database if not already present, get if is present. """
url = api_url+'users/social/'
payload = {
'user': int(user),
'provider': 'discord',
'uid': str(uid)
}
print(json.dumps(payload))
r = requests.put(url, data=json.dumps(paylo... | [
"def",
"import_discord_user",
"(",
"self",
",",
"uid",
",",
"user",
")",
":",
"url",
"=",
"api_url",
"+",
"'users/social/'",
"payload",
"=",
"{",
"'user'",
":",
"int",
"(",
"user",
")",
",",
"'provider'",
":",
"'discord'",
",",
"'uid'",
":",
"str",
"("... | Add a discord user to the database if not already present, get if is present. | [
"Add",
"a",
"discord",
"user",
"to",
"the",
"database",
"if",
"not",
"already",
"present",
"get",
"if",
"is",
"present",
"."
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L121-L133 |
TrainerDex/TrainerDex.py | trainerdex/client.py | Client.create_user | def create_user(self, username, first_name=None, last_name=None):
"""
Creates a new user object on database
Returns the User Object. Must be linked to a new trainer soon after
"""
url = api_url+'users/'
payload = {
'username':username
}
if first_name:
payload['first_name'] = first_name
if las... | python | def create_user(self, username, first_name=None, last_name=None):
"""
Creates a new user object on database
Returns the User Object. Must be linked to a new trainer soon after
"""
url = api_url+'users/'
payload = {
'username':username
}
if first_name:
payload['first_name'] = first_name
if las... | [
"def",
"create_user",
"(",
"self",
",",
"username",
",",
"first_name",
"=",
"None",
",",
"last_name",
"=",
"None",
")",
":",
"url",
"=",
"api_url",
"+",
"'users/'",
"payload",
"=",
"{",
"'username'",
":",
"username",
"}",
"if",
"first_name",
":",
"payloa... | Creates a new user object on database
Returns the User Object. Must be linked to a new trainer soon after | [
"Creates",
"a",
"new",
"user",
"object",
"on",
"database",
"Returns",
"the",
"User",
"Object",
".",
"Must",
"be",
"linked",
"to",
"a",
"new",
"trainer",
"soon",
"after"
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L135-L152 |
TrainerDex/TrainerDex.py | trainerdex/client.py | Client.update_user | def update_user(self, user, username=None, first_name=None, last_name=None):
"""Update user info"""
if not isinstance(user, User):
raise ValueError
args = locals()
url = api_url+'users/'+str(user.id)+'/'
payload = {}
for i in args:
if args[i] is not None and i not in ['self', 'user']:
payload[i... | python | def update_user(self, user, username=None, first_name=None, last_name=None):
"""Update user info"""
if not isinstance(user, User):
raise ValueError
args = locals()
url = api_url+'users/'+str(user.id)+'/'
payload = {}
for i in args:
if args[i] is not None and i not in ['self', 'user']:
payload[i... | [
"def",
"update_user",
"(",
"self",
",",
"user",
",",
"username",
"=",
"None",
",",
"first_name",
"=",
"None",
",",
"last_name",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"user",
",",
"User",
")",
":",
"raise",
"ValueError",
"args",
"=",
... | Update user info | [
"Update",
"user",
"info"
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L154-L168 |
TrainerDex/TrainerDex.py | trainerdex/client.py | Client.get_trainer | def get_trainer(self, id_, respect_privacy=True, detail=True):
"""Returns the Trainer object for the ID"""
parameters = {}
if respect_privacy is False:
parameters['statistics'] = 'force'
if detail is False:
parameters['detail'] = 'low'
r = requests.get(api_url+'trainers/'+str(id_)+'/', headers=se... | python | def get_trainer(self, id_, respect_privacy=True, detail=True):
"""Returns the Trainer object for the ID"""
parameters = {}
if respect_privacy is False:
parameters['statistics'] = 'force'
if detail is False:
parameters['detail'] = 'low'
r = requests.get(api_url+'trainers/'+str(id_)+'/', headers=se... | [
"def",
"get_trainer",
"(",
"self",
",",
"id_",
",",
"respect_privacy",
"=",
"True",
",",
"detail",
"=",
"True",
")",
":",
"parameters",
"=",
"{",
"}",
"if",
"respect_privacy",
"is",
"False",
":",
"parameters",
"[",
"'statistics'",
"]",
"=",
"'force'",
"i... | Returns the Trainer object for the ID | [
"Returns",
"the",
"Trainer",
"object",
"for",
"the",
"ID"
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L170-L182 |
TrainerDex/TrainerDex.py | trainerdex/client.py | Client.get_detailed_update | def get_detailed_update(self, uid, uuid):
"""Returns the update object for the ID"""
r = requests.get(api_url+'users/'+str(uid)+'/update/'+str(uuid)+'/', headers=self.headers)
print(request_status(r))
r.raise_for_status()
return Update(r.json()) | python | def get_detailed_update(self, uid, uuid):
"""Returns the update object for the ID"""
r = requests.get(api_url+'users/'+str(uid)+'/update/'+str(uuid)+'/', headers=self.headers)
print(request_status(r))
r.raise_for_status()
return Update(r.json()) | [
"def",
"get_detailed_update",
"(",
"self",
",",
"uid",
",",
"uuid",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"api_url",
"+",
"'users/'",
"+",
"str",
"(",
"uid",
")",
"+",
"'/update/'",
"+",
"str",
"(",
"uuid",
")",
"+",
"'/'",
",",
"headers... | Returns the update object for the ID | [
"Returns",
"the",
"update",
"object",
"for",
"the",
"ID"
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L184-L190 |
TrainerDex/TrainerDex.py | trainerdex/client.py | Client.get_user | def get_user(self, uid):
"""Returns the User object for the ID"""
r = requests.get(api_url+'users/'+str(uid)+'/', headers=self.headers)
print(request_status(r))
r.raise_for_status()
return User(r.json()) | python | def get_user(self, uid):
"""Returns the User object for the ID"""
r = requests.get(api_url+'users/'+str(uid)+'/', headers=self.headers)
print(request_status(r))
r.raise_for_status()
return User(r.json()) | [
"def",
"get_user",
"(",
"self",
",",
"uid",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"api_url",
"+",
"'users/'",
"+",
"str",
"(",
"uid",
")",
"+",
"'/'",
",",
"headers",
"=",
"self",
".",
"headers",
")",
"print",
"(",
"request_status",
"(",... | Returns the User object for the ID | [
"Returns",
"the",
"User",
"object",
"for",
"the",
"ID"
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L192-L198 |
TrainerDex/TrainerDex.py | trainerdex/client.py | Client.get_discord_user | def get_discord_user(self, uid=None, user=None, trainer=None):
"""Returns the DiscordUsers object for the ID
Expects list of string representions discord IDs, trainer IDs or user IDs
Returns DiscordUser objects
"""
uids = ','.join(uid) if uid else None
users =','.join(user) if user else None
trainers = ',... | python | def get_discord_user(self, uid=None, user=None, trainer=None):
"""Returns the DiscordUsers object for the ID
Expects list of string representions discord IDs, trainer IDs or user IDs
Returns DiscordUser objects
"""
uids = ','.join(uid) if uid else None
users =','.join(user) if user else None
trainers = ',... | [
"def",
"get_discord_user",
"(",
"self",
",",
"uid",
"=",
"None",
",",
"user",
"=",
"None",
",",
"trainer",
"=",
"None",
")",
":",
"uids",
"=",
"','",
".",
"join",
"(",
"uid",
")",
"if",
"uid",
"else",
"None",
"users",
"=",
"','",
".",
"join",
"("... | Returns the DiscordUsers object for the ID
Expects list of string representions discord IDs, trainer IDs or user IDs
Returns DiscordUser objects | [
"Returns",
"the",
"DiscordUsers",
"object",
"for",
"the",
"ID",
"Expects",
"list",
"of",
"string",
"representions",
"discord",
"IDs",
"trainer",
"IDs",
"or",
"user",
"IDs",
"Returns",
"DiscordUser",
"objects"
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L200-L221 |
TrainerDex/TrainerDex.py | trainerdex/client.py | Client.get_all_users | def get_all_users(self):
"""Returns all the users"""
r = requests.get(api_url+'users/', headers=self.headers)
print(request_status(r))
r.raise_for_status()
output = r.json()
result = []
for x in output:
result.append(User(x))
return result | python | def get_all_users(self):
"""Returns all the users"""
r = requests.get(api_url+'users/', headers=self.headers)
print(request_status(r))
r.raise_for_status()
output = r.json()
result = []
for x in output:
result.append(User(x))
return result | [
"def",
"get_all_users",
"(",
"self",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"api_url",
"+",
"'users/'",
",",
"headers",
"=",
"self",
".",
"headers",
")",
"print",
"(",
"request_status",
"(",
"r",
")",
")",
"r",
".",
"raise_for_status",
"(",
... | Returns all the users | [
"Returns",
"all",
"the",
"users"
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L223-L233 |
TrainerDex/TrainerDex.py | trainerdex/client.py | Client.get_discord_leaderboard | def get_discord_leaderboard(self, guild):
"""
Expects: `int` - Discord Guild ID
Returns: `trainerdex.DiscordLeaderboard`
"""
r = requests.get(api_url+'leaderboard/discord/'+str(guild)+'/', headers=self.headers)
print(request_status(r))
r.raise_for_status()
return DiscordLeaderboard(r.json()) | python | def get_discord_leaderboard(self, guild):
"""
Expects: `int` - Discord Guild ID
Returns: `trainerdex.DiscordLeaderboard`
"""
r = requests.get(api_url+'leaderboard/discord/'+str(guild)+'/', headers=self.headers)
print(request_status(r))
r.raise_for_status()
return DiscordLeaderboard(r.json()) | [
"def",
"get_discord_leaderboard",
"(",
"self",
",",
"guild",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"api_url",
"+",
"'leaderboard/discord/'",
"+",
"str",
"(",
"guild",
")",
"+",
"'/'",
",",
"headers",
"=",
"self",
".",
"headers",
")",
"print",
... | Expects: `int` - Discord Guild ID
Returns: `trainerdex.DiscordLeaderboard` | [
"Expects",
":",
"int",
"-",
"Discord",
"Guild",
"ID",
"Returns",
":",
"trainerdex",
".",
"DiscordLeaderboard"
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L235-L244 |
TrainerDex/TrainerDex.py | trainerdex/client.py | Client.get_worldwide_leaderboard | def get_worldwide_leaderboard(self):
"""
Returns: `trainerdex.WorldwideLeaderboard`
"""
r = requests.get(api_url+'leaderboard/', headers=self.headers)
print(request_status(r))
r.raise_for_status()
return WorldwideLeaderboard(r.json()) | python | def get_worldwide_leaderboard(self):
"""
Returns: `trainerdex.WorldwideLeaderboard`
"""
r = requests.get(api_url+'leaderboard/', headers=self.headers)
print(request_status(r))
r.raise_for_status()
return WorldwideLeaderboard(r.json()) | [
"def",
"get_worldwide_leaderboard",
"(",
"self",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"api_url",
"+",
"'leaderboard/'",
",",
"headers",
"=",
"self",
".",
"headers",
")",
"print",
"(",
"request_status",
"(",
"r",
")",
")",
"r",
".",
"raise_for... | Returns: `trainerdex.WorldwideLeaderboard` | [
"Returns",
":",
"trainerdex",
".",
"WorldwideLeaderboard"
] | train | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L247-L255 |
rvswift/EB | EB/builder/utilities/ensemble_storage.py | EnsembleStorage.set_prop | def set_prop(self, prop, value, ef=None):
"""
set attributes values
:param prop:
:param value:
:param ef:
:return:
"""
if ef:
# prop should be restricted to n_decoys, an int, the no. of decoys corresponding to a given FPF.
# value i... | python | def set_prop(self, prop, value, ef=None):
"""
set attributes values
:param prop:
:param value:
:param ef:
:return:
"""
if ef:
# prop should be restricted to n_decoys, an int, the no. of decoys corresponding to a given FPF.
# value i... | [
"def",
"set_prop",
"(",
"self",
",",
"prop",
",",
"value",
",",
"ef",
"=",
"None",
")",
":",
"if",
"ef",
":",
"# prop should be restricted to n_decoys, an int, the no. of decoys corresponding to a given FPF.",
"# value is restricted to the corresponding enrichment factor and shou... | set attributes values
:param prop:
:param value:
:param ef:
:return: | [
"set",
"attributes",
"values",
":",
"param",
"prop",
":",
":",
"param",
"value",
":",
":",
"param",
"ef",
":",
":",
"return",
":"
] | train | https://github.com/rvswift/EB/blob/341880b79faf8147dc9fa6e90438531cd09fabcc/EB/builder/utilities/ensemble_storage.py#L17-L35 |
rvswift/EB | EB/builder/utilities/ensemble_storage.py | EnsembleStorage.get_prop | def get_prop(self, prop, ef=None):
"""
return property attributes
:param prop:
:return:
"""
if ef:
return self.ef[prop]
else:
if prop == 'auc':
return self.auc
elif prop == 'ensemble':
return self... | python | def get_prop(self, prop, ef=None):
"""
return property attributes
:param prop:
:return:
"""
if ef:
return self.ef[prop]
else:
if prop == 'auc':
return self.auc
elif prop == 'ensemble':
return self... | [
"def",
"get_prop",
"(",
"self",
",",
"prop",
",",
"ef",
"=",
"None",
")",
":",
"if",
"ef",
":",
"return",
"self",
".",
"ef",
"[",
"prop",
"]",
"else",
":",
"if",
"prop",
"==",
"'auc'",
":",
"return",
"self",
".",
"auc",
"elif",
"prop",
"==",
"'... | return property attributes
:param prop:
:return: | [
"return",
"property",
"attributes",
":",
"param",
"prop",
":",
":",
"return",
":"
] | train | https://github.com/rvswift/EB/blob/341880b79faf8147dc9fa6e90438531cd09fabcc/EB/builder/utilities/ensemble_storage.py#L37-L49 |
syndbg/demonoid-api | demonoid/urls.py | Url.combine | def combine(self, path):
"""
Gives a combined `self.BASE_URL` with the given `path`.
Used to build urls without modifying the current `self.path`.
Handles conflicts of trailing or preceding slashes.
:param str path: `path` to append
:return: combined `self.base_url` and ... | python | def combine(self, path):
"""
Gives a combined `self.BASE_URL` with the given `path`.
Used to build urls without modifying the current `self.path`.
Handles conflicts of trailing or preceding slashes.
:param str path: `path` to append
:return: combined `self.base_url` and ... | [
"def",
"combine",
"(",
"self",
",",
"path",
")",
":",
"url",
"=",
"self",
".",
"base_url",
"if",
"url",
".",
"endswith",
"(",
"'/'",
")",
"and",
"path",
".",
"startswith",
"(",
"'/'",
")",
":",
"url",
"+=",
"path",
"[",
"1",
":",
"]",
"elif",
"... | Gives a combined `self.BASE_URL` with the given `path`.
Used to build urls without modifying the current `self.path`.
Handles conflicts of trailing or preceding slashes.
:param str path: `path` to append
:return: combined `self.base_url` and given `path`.
:rtype: str | [
"Gives",
"a",
"combined",
"self",
".",
"BASE_URL",
"with",
"the",
"given",
"path",
".",
"Used",
"to",
"build",
"urls",
"without",
"modifying",
"the",
"current",
"self",
".",
"path",
".",
"Handles",
"conflicts",
"of",
"trailing",
"or",
"preceding",
"slashes",... | train | https://github.com/syndbg/demonoid-api/blob/518aa389ac91b5243b92fc19923103f31041a61e/demonoid/urls.py#L69-L86 |
syndbg/demonoid-api | demonoid/urls.py | Url.update_DOM | def update_DOM(self):
"""
Makes a request and updates `self._DOM`.
Worth using only if you manually change `self.base_url` or `self.path`.
:return: self
:rtype: Url
"""
response = self.fetch()
self._DOM = html.fromstring(response.text)
return self | python | def update_DOM(self):
"""
Makes a request and updates `self._DOM`.
Worth using only if you manually change `self.base_url` or `self.path`.
:return: self
:rtype: Url
"""
response = self.fetch()
self._DOM = html.fromstring(response.text)
return self | [
"def",
"update_DOM",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"fetch",
"(",
")",
"self",
".",
"_DOM",
"=",
"html",
".",
"fromstring",
"(",
"response",
".",
"text",
")",
"return",
"self"
] | Makes a request and updates `self._DOM`.
Worth using only if you manually change `self.base_url` or `self.path`.
:return: self
:rtype: Url | [
"Makes",
"a",
"request",
"and",
"updates",
"self",
".",
"_DOM",
".",
"Worth",
"using",
"only",
"if",
"you",
"manually",
"change",
"self",
".",
"base_url",
"or",
"self",
".",
"path",
"."
] | train | https://github.com/syndbg/demonoid-api/blob/518aa389ac91b5243b92fc19923103f31041a61e/demonoid/urls.py#L100-L110 |
syndbg/demonoid-api | demonoid/urls.py | Url.fetch | def fetch(self):
"""
Makes a request to combined url with `self._params` as parameters.
If the server at combined url responds with Client or Server error, raises an exception.
:return: the response from combined url
:rtype: requests.models.Response
"""
response ... | python | def fetch(self):
"""
Makes a request to combined url with `self._params` as parameters.
If the server at combined url responds with Client or Server error, raises an exception.
:return: the response from combined url
:rtype: requests.models.Response
"""
response ... | [
"def",
"fetch",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"_session",
".",
"get",
"(",
"self",
".",
"url",
",",
"params",
"=",
"self",
".",
"params",
")",
"response",
".",
"raise_for_status",
"(",
")",
"return",
"response"
] | Makes a request to combined url with `self._params` as parameters.
If the server at combined url responds with Client or Server error, raises an exception.
:return: the response from combined url
:rtype: requests.models.Response | [
"Makes",
"a",
"request",
"to",
"combined",
"url",
"with",
"self",
".",
"_params",
"as",
"parameters",
".",
"If",
"the",
"server",
"at",
"combined",
"url",
"responds",
"with",
"Client",
"or",
"Server",
"error",
"raises",
"an",
"exception",
"."
] | train | https://github.com/syndbg/demonoid-api/blob/518aa389ac91b5243b92fc19923103f31041a61e/demonoid/urls.py#L112-L122 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/main.py | init_environment | def init_environment():
"""Set environment variables that are important for the pipeline.
:returns: None
:rtype: None
:raises: None
"""
os.environ['DJANGO_SETTINGS_MODULE'] = 'jukeboxcore.djsettings'
pluginpath = os.pathsep.join((os.environ.get('JUKEBOX_PLUGIN_PATH', ''), constants.BUILTIN_... | python | def init_environment():
"""Set environment variables that are important for the pipeline.
:returns: None
:rtype: None
:raises: None
"""
os.environ['DJANGO_SETTINGS_MODULE'] = 'jukeboxcore.djsettings'
pluginpath = os.pathsep.join((os.environ.get('JUKEBOX_PLUGIN_PATH', ''), constants.BUILTIN_... | [
"def",
"init_environment",
"(",
")",
":",
"os",
".",
"environ",
"[",
"'DJANGO_SETTINGS_MODULE'",
"]",
"=",
"'jukeboxcore.djsettings'",
"pluginpath",
"=",
"os",
".",
"pathsep",
".",
"join",
"(",
"(",
"os",
".",
"environ",
".",
"get",
"(",
"'JUKEBOX_PLUGIN_PATH'... | Set environment variables that are important for the pipeline.
:returns: None
:rtype: None
:raises: None | [
"Set",
"environment",
"variables",
"that",
"are",
"important",
"for",
"the",
"pipeline",
"."
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/main.py#L13-L22 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/main.py | unload_modules | def unload_modules():
""" Unload all modules of the jukebox package and all plugin modules
Python provides the ``reload`` command for reloading modules. The major drawback is, that if this module is loaded in any other module
the source code will not be resourced!
If you want to reload the code because... | python | def unload_modules():
""" Unload all modules of the jukebox package and all plugin modules
Python provides the ``reload`` command for reloading modules. The major drawback is, that if this module is loaded in any other module
the source code will not be resourced!
If you want to reload the code because... | [
"def",
"unload_modules",
"(",
")",
":",
"mods",
"=",
"set",
"(",
"[",
"]",
")",
"for",
"m",
"in",
"sys",
".",
"modules",
":",
"if",
"m",
".",
"startswith",
"(",
"'jukebox'",
")",
":",
"mods",
".",
"add",
"(",
"m",
")",
"pm",
"=",
"PluginManager",... | Unload all modules of the jukebox package and all plugin modules
Python provides the ``reload`` command for reloading modules. The major drawback is, that if this module is loaded in any other module
the source code will not be resourced!
If you want to reload the code because you changed the source file, ... | [
"Unload",
"all",
"modules",
"of",
"the",
"jukebox",
"package",
"and",
"all",
"plugin",
"modules"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/main.py#L36-L55 |
epfl-idevelop/epfl-ldap | epflldap/ldap_search.py | _get_LDAP_connection | def _get_LDAP_connection():
"""
Return a LDAP connection
"""
server = ldap3.Server('ldap://' + get_optional_env('EPFL_LDAP_SERVER_FOR_SEARCH'))
connection = ldap3.Connection(server)
connection.open()
return connection, get_optional_env('EPFL_LDAP_BASE_DN_FOR_SEARCH') | python | def _get_LDAP_connection():
"""
Return a LDAP connection
"""
server = ldap3.Server('ldap://' + get_optional_env('EPFL_LDAP_SERVER_FOR_SEARCH'))
connection = ldap3.Connection(server)
connection.open()
return connection, get_optional_env('EPFL_LDAP_BASE_DN_FOR_SEARCH') | [
"def",
"_get_LDAP_connection",
"(",
")",
":",
"server",
"=",
"ldap3",
".",
"Server",
"(",
"'ldap://'",
"+",
"get_optional_env",
"(",
"'EPFL_LDAP_SERVER_FOR_SEARCH'",
")",
")",
"connection",
"=",
"ldap3",
".",
"Connection",
"(",
"server",
")",
"connection",
".",
... | Return a LDAP connection | [
"Return",
"a",
"LDAP",
"connection"
] | train | https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/ldap_search.py#L7-L15 |
epfl-idevelop/epfl-ldap | epflldap/ldap_search.py | LDAP_search | def LDAP_search(pattern_search, attribute):
"""
Do a LDAP search
"""
connection, ldap_base = _get_LDAP_connection()
connection.search(
search_base=ldap_base,
search_filter=pattern_search,
attributes=[attribute]
)
return connection.response | python | def LDAP_search(pattern_search, attribute):
"""
Do a LDAP search
"""
connection, ldap_base = _get_LDAP_connection()
connection.search(
search_base=ldap_base,
search_filter=pattern_search,
attributes=[attribute]
)
return connection.response | [
"def",
"LDAP_search",
"(",
"pattern_search",
",",
"attribute",
")",
":",
"connection",
",",
"ldap_base",
"=",
"_get_LDAP_connection",
"(",
")",
"connection",
".",
"search",
"(",
"search_base",
"=",
"ldap_base",
",",
"search_filter",
"=",
"pattern_search",
",",
"... | Do a LDAP search | [
"Do",
"a",
"LDAP",
"search"
] | train | https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/ldap_search.py#L18-L29 |
epfl-idevelop/epfl-ldap | epflldap/ldap_search.py | is_unit_exist | def is_unit_exist(unit_id):
"""
Return True if the unit 'unid_id' exists.
Otherwise return False
"""
attribute = 'objectClass'
response = LDAP_search(
pattern_search="(uniqueidentifier={})".format(unit_id),
attribute=attribute
)
try:
unit_exist = 'EPFLorganization... | python | def is_unit_exist(unit_id):
"""
Return True if the unit 'unid_id' exists.
Otherwise return False
"""
attribute = 'objectClass'
response = LDAP_search(
pattern_search="(uniqueidentifier={})".format(unit_id),
attribute=attribute
)
try:
unit_exist = 'EPFLorganization... | [
"def",
"is_unit_exist",
"(",
"unit_id",
")",
":",
"attribute",
"=",
"'objectClass'",
"response",
"=",
"LDAP_search",
"(",
"pattern_search",
"=",
"\"(uniqueidentifier={})\"",
".",
"format",
"(",
"unit_id",
")",
",",
"attribute",
"=",
"attribute",
")",
"try",
":",... | Return True if the unit 'unid_id' exists.
Otherwise return False | [
"Return",
"True",
"if",
"the",
"unit",
"unid_id",
"exists",
".",
"Otherwise",
"return",
"False"
] | train | https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/ldap_search.py#L36-L51 |
epfl-idevelop/epfl-ldap | epflldap/ldap_search.py | get_unit_name | def get_unit_name(unit_id):
"""
Return the unit name to the unit 'unit_id'
"""
attribute = 'cn'
response = LDAP_search(
pattern_search='(uniqueIdentifier={})'.format(unit_id),
attribute=attribute
)
try:
unit_name = get_attribute(response, attribute)
except Excepti... | python | def get_unit_name(unit_id):
"""
Return the unit name to the unit 'unit_id'
"""
attribute = 'cn'
response = LDAP_search(
pattern_search='(uniqueIdentifier={})'.format(unit_id),
attribute=attribute
)
try:
unit_name = get_attribute(response, attribute)
except Excepti... | [
"def",
"get_unit_name",
"(",
"unit_id",
")",
":",
"attribute",
"=",
"'cn'",
"response",
"=",
"LDAP_search",
"(",
"pattern_search",
"=",
"'(uniqueIdentifier={})'",
".",
"format",
"(",
"unit_id",
")",
",",
"attribute",
"=",
"attribute",
")",
"try",
":",
"unit_na... | Return the unit name to the unit 'unit_id' | [
"Return",
"the",
"unit",
"name",
"to",
"the",
"unit",
"unit_id"
] | train | https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/ldap_search.py#L54-L68 |
epfl-idevelop/epfl-ldap | epflldap/ldap_search.py | get_unit_id | def get_unit_id(unit_name):
"""
Return the unit id to the unit 'unit_name'
"""
unit_name = unit_name.lower()
attribute = 'uniqueIdentifier'
response = LDAP_search(
pattern_search='(cn={})'.format(unit_name),
attribute=attribute
)
unit_id = ""
try:
for element... | python | def get_unit_id(unit_name):
"""
Return the unit id to the unit 'unit_name'
"""
unit_name = unit_name.lower()
attribute = 'uniqueIdentifier'
response = LDAP_search(
pattern_search='(cn={})'.format(unit_name),
attribute=attribute
)
unit_id = ""
try:
for element... | [
"def",
"get_unit_id",
"(",
"unit_name",
")",
":",
"unit_name",
"=",
"unit_name",
".",
"lower",
"(",
")",
"attribute",
"=",
"'uniqueIdentifier'",
"response",
"=",
"LDAP_search",
"(",
"pattern_search",
"=",
"'(cn={})'",
".",
"format",
"(",
"unit_name",
")",
",",... | Return the unit id to the unit 'unit_name' | [
"Return",
"the",
"unit",
"id",
"to",
"the",
"unit",
"unit_name"
] | train | https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/ldap_search.py#L71-L93 |
epfl-idevelop/epfl-ldap | epflldap/ldap_search.py | get_units | def get_units(username):
"""
Return all units of user 'username'
"""
connection, ldap_base = _get_LDAP_connection()
# Search the user dn
connection.search(
search_base=ldap_base,
search_filter='(uid={}@*)'.format(username),
)
# For each user dn give me the unit
dn_l... | python | def get_units(username):
"""
Return all units of user 'username'
"""
connection, ldap_base = _get_LDAP_connection()
# Search the user dn
connection.search(
search_base=ldap_base,
search_filter='(uid={}@*)'.format(username),
)
# For each user dn give me the unit
dn_l... | [
"def",
"get_units",
"(",
"username",
")",
":",
"connection",
",",
"ldap_base",
"=",
"_get_LDAP_connection",
"(",
")",
"# Search the user dn",
"connection",
".",
"search",
"(",
"search_base",
"=",
"ldap_base",
",",
"search_filter",
"=",
"'(uid={}@*)'",
".",
"format... | Return all units of user 'username' | [
"Return",
"all",
"units",
"of",
"user",
"username"
] | train | https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/ldap_search.py#L96-L118 |
epfl-idevelop/epfl-ldap | epflldap/ldap_search.py | get_username | def get_username(sciper):
"""
Return username of user
"""
attribute = 'uid'
response = LDAP_search(
pattern_search='(uniqueIdentifier={})'.format(sciper),
attribute=attribute
)
try:
username = get_attribute(response, attribute)
except Exception:
raise Epfl... | python | def get_username(sciper):
"""
Return username of user
"""
attribute = 'uid'
response = LDAP_search(
pattern_search='(uniqueIdentifier={})'.format(sciper),
attribute=attribute
)
try:
username = get_attribute(response, attribute)
except Exception:
raise Epfl... | [
"def",
"get_username",
"(",
"sciper",
")",
":",
"attribute",
"=",
"'uid'",
"response",
"=",
"LDAP_search",
"(",
"pattern_search",
"=",
"'(uniqueIdentifier={})'",
".",
"format",
"(",
"sciper",
")",
",",
"attribute",
"=",
"attribute",
")",
"try",
":",
"username"... | Return username of user | [
"Return",
"username",
"of",
"user"
] | train | https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/ldap_search.py#L137-L150 |
epfl-idevelop/epfl-ldap | epflldap/ldap_search.py | get_email | def get_email(sciper):
"""
Return email of user
"""
attribute = 'mail'
response = LDAP_search(
pattern_search='(uniqueIdentifier={})'.format(sciper),
attribute=attribute
)
try:
email = get_attribute(response, attribute)
except Exception:
raise EpflLdapExce... | python | def get_email(sciper):
"""
Return email of user
"""
attribute = 'mail'
response = LDAP_search(
pattern_search='(uniqueIdentifier={})'.format(sciper),
attribute=attribute
)
try:
email = get_attribute(response, attribute)
except Exception:
raise EpflLdapExce... | [
"def",
"get_email",
"(",
"sciper",
")",
":",
"attribute",
"=",
"'mail'",
"response",
"=",
"LDAP_search",
"(",
"pattern_search",
"=",
"'(uniqueIdentifier={})'",
".",
"format",
"(",
"sciper",
")",
",",
"attribute",
"=",
"attribute",
")",
"try",
":",
"email",
"... | Return email of user | [
"Return",
"email",
"of",
"user"
] | train | https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/ldap_search.py#L153-L166 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/errors/ApplicationException.py | ApplicationException.with_code | def with_code(self, code):
"""
Sets a unique error code.
This method returns reference to this exception to implement Builder pattern to chain additional calls.
:param code: a unique error code
:return: this exception object
"""
self.code = code if code != None ... | python | def with_code(self, code):
"""
Sets a unique error code.
This method returns reference to this exception to implement Builder pattern to chain additional calls.
:param code: a unique error code
:return: this exception object
"""
self.code = code if code != None ... | [
"def",
"with_code",
"(",
"self",
",",
"code",
")",
":",
"self",
".",
"code",
"=",
"code",
"if",
"code",
"!=",
"None",
"else",
"'UNKNOWN'",
"self",
".",
"name",
"=",
"code",
"return",
"self"
] | Sets a unique error code.
This method returns reference to this exception to implement Builder pattern to chain additional calls.
:param code: a unique error code
:return: this exception object | [
"Sets",
"a",
"unique",
"error",
"code",
".",
"This",
"method",
"returns",
"reference",
"to",
"this",
"exception",
"to",
"implement",
"Builder",
"pattern",
"to",
"chain",
"additional",
"calls",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/errors/ApplicationException.py#L131-L142 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/errors/ApplicationException.py | ApplicationException.with_details | def with_details(self, key, value):
"""
Sets a parameter for additional error details.
This details can be used to restore error description in other languages.
This method returns reference to this exception to implement Builder pattern to chain additional calls.
:param key: a... | python | def with_details(self, key, value):
"""
Sets a parameter for additional error details.
This details can be used to restore error description in other languages.
This method returns reference to this exception to implement Builder pattern to chain additional calls.
:param key: a... | [
"def",
"with_details",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"details",
"=",
"self",
".",
"details",
"if",
"self",
".",
"details",
"!=",
"None",
"else",
"{",
"}",
"self",
".",
"details",
"[",
"key",
"]",
"=",
"value",
"retur... | Sets a parameter for additional error details.
This details can be used to restore error description in other languages.
This method returns reference to this exception to implement Builder pattern to chain additional calls.
:param key: a details parameter name
:param value: a details... | [
"Sets",
"a",
"parameter",
"for",
"additional",
"error",
"details",
".",
"This",
"details",
"can",
"be",
"used",
"to",
"restore",
"error",
"description",
"in",
"other",
"languages",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/errors/ApplicationException.py#L156-L171 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/errors/ApplicationException.py | ApplicationException.wrap | def wrap(self, cause):
"""
Wraps another exception into an application exception object.
If original exception is of ApplicationException type it is returned without changes.
Otherwise a new ApplicationException is created and original error is set as its cause.
:param cause: a... | python | def wrap(self, cause):
"""
Wraps another exception into an application exception object.
If original exception is of ApplicationException type it is returned without changes.
Otherwise a new ApplicationException is created and original error is set as its cause.
:param cause: a... | [
"def",
"wrap",
"(",
"self",
",",
"cause",
")",
":",
"if",
"isinstance",
"(",
"cause",
",",
"ApplicationException",
")",
":",
"return",
"cause",
"self",
".",
"with_cause",
"(",
"cause",
")",
"return",
"self"
] | Wraps another exception into an application exception object.
If original exception is of ApplicationException type it is returned without changes.
Otherwise a new ApplicationException is created and original error is set as its cause.
:param cause: an original error object
:return: a... | [
"Wraps",
"another",
"exception",
"into",
"an",
"application",
"exception",
"object",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/errors/ApplicationException.py#L199-L214 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/errors/ApplicationException.py | ApplicationException.wrap_exception | def wrap_exception(exception, cause):
"""
Wraps another exception into specified application exception object.
If original exception is of ApplicationException type it is returned without changes.
Otherwise the original error is set as a cause to specified ApplicationException object.
... | python | def wrap_exception(exception, cause):
"""
Wraps another exception into specified application exception object.
If original exception is of ApplicationException type it is returned without changes.
Otherwise the original error is set as a cause to specified ApplicationException object.
... | [
"def",
"wrap_exception",
"(",
"exception",
",",
"cause",
")",
":",
"if",
"isinstance",
"(",
"cause",
",",
"ApplicationException",
")",
":",
"return",
"cause",
"exception",
".",
"with_cause",
"(",
"cause",
")",
"return",
"exception"
] | Wraps another exception into specified application exception object.
If original exception is of ApplicationException type it is returned without changes.
Otherwise the original error is set as a cause to specified ApplicationException object.
:param exception: an ApplicationException object t... | [
"Wraps",
"another",
"exception",
"into",
"specified",
"application",
"exception",
"object",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/errors/ApplicationException.py#L217-L234 |
FujiMakoto/AgentML | agentml/parser/tags/var.py | Var.value | def value(self):
"""
Return the current value of a variable
"""
# Does the variable name have tags to parse?
if len(self._element):
var = ''.join(map(str, self.trigger.agentml.parse_tags(self._element, self.trigger)))
else:
var = self._element.text... | python | def value(self):
"""
Return the current value of a variable
"""
# Does the variable name have tags to parse?
if len(self._element):
var = ''.join(map(str, self.trigger.agentml.parse_tags(self._element, self.trigger)))
else:
var = self._element.text... | [
"def",
"value",
"(",
"self",
")",
":",
"# Does the variable name have tags to parse?",
"if",
"len",
"(",
"self",
".",
"_element",
")",
":",
"var",
"=",
"''",
".",
"join",
"(",
"map",
"(",
"str",
",",
"self",
".",
"trigger",
".",
"agentml",
".",
"parse_ta... | Return the current value of a variable | [
"Return",
"the",
"current",
"value",
"of",
"a",
"variable"
] | train | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/parser/tags/var.py#L28-L55 |
rbarrois/django-batchform | batchform/parsers/csv.py | BaseCsvParser.reopen | def reopen(self, file_obj):
"""Reopen the file-like object in a safe manner."""
file_obj.open('U')
if sys.version_info[0] <= 2:
return file_obj
else:
return codecs.getreader('utf-8')(file_obj) | python | def reopen(self, file_obj):
"""Reopen the file-like object in a safe manner."""
file_obj.open('U')
if sys.version_info[0] <= 2:
return file_obj
else:
return codecs.getreader('utf-8')(file_obj) | [
"def",
"reopen",
"(",
"self",
",",
"file_obj",
")",
":",
"file_obj",
".",
"open",
"(",
"'U'",
")",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"<=",
"2",
":",
"return",
"file_obj",
"else",
":",
"return",
"codecs",
".",
"getreader",
"(",
"'utf-8'... | Reopen the file-like object in a safe manner. | [
"Reopen",
"the",
"file",
"-",
"like",
"object",
"in",
"a",
"safe",
"manner",
"."
] | train | https://github.com/rbarrois/django-batchform/blob/f6b659a6790750285af248ccd1d4d178ecbad129/batchform/parsers/csv.py#L36-L42 |
cdumay/cdumay-rest-client | src/cdumay_rest_client/tracing.py | RESTClientRequestSpan.inject | def inject(cls, span, obj):
""" Injects the span context into a `carrier` object.
:param opentracing.span.SpanContext span: the SpanContext instance
:param Any obj: Object to use as context
"""
opentracing.tracer.inject(span, cls.FORMAT, obj['headers']) | python | def inject(cls, span, obj):
""" Injects the span context into a `carrier` object.
:param opentracing.span.SpanContext span: the SpanContext instance
:param Any obj: Object to use as context
"""
opentracing.tracer.inject(span, cls.FORMAT, obj['headers']) | [
"def",
"inject",
"(",
"cls",
",",
"span",
",",
"obj",
")",
":",
"opentracing",
".",
"tracer",
".",
"inject",
"(",
"span",
",",
"cls",
".",
"FORMAT",
",",
"obj",
"[",
"'headers'",
"]",
")"
] | Injects the span context into a `carrier` object.
:param opentracing.span.SpanContext span: the SpanContext instance
:param Any obj: Object to use as context | [
"Injects",
"the",
"span",
"context",
"into",
"a",
"carrier",
"object",
"."
] | train | https://github.com/cdumay/cdumay-rest-client/blob/bca34d45748cb8227a7492af5ccfead3d8ab435d/src/cdumay_rest_client/tracing.py#L34-L40 |
cdumay/cdumay-rest-client | src/cdumay_rest_client/tracing.py | RESTClientRequestSpan._postrun | def _postrun(cls, span, obj, **kwargs):
""" Trigger to execute just before closing the span
:param opentracing.span.Span span: the SpanContext instance
:param Any obj: Object to use as context
:param dict kwargs: additional data
"""
span.set_tag("response.status_code", ... | python | def _postrun(cls, span, obj, **kwargs):
""" Trigger to execute just before closing the span
:param opentracing.span.Span span: the SpanContext instance
:param Any obj: Object to use as context
:param dict kwargs: additional data
"""
span.set_tag("response.status_code", ... | [
"def",
"_postrun",
"(",
"cls",
",",
"span",
",",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"span",
".",
"set_tag",
"(",
"\"response.status_code\"",
",",
"obj",
".",
"status_code",
")",
"span",
".",
"set_tag",
"(",
"\"response.content_lenght\"",
",",
"len",... | Trigger to execute just before closing the span
:param opentracing.span.Span span: the SpanContext instance
:param Any obj: Object to use as context
:param dict kwargs: additional data | [
"Trigger",
"to",
"execute",
"just",
"before",
"closing",
"the",
"span"
] | train | https://github.com/cdumay/cdumay-rest-client/blob/bca34d45748cb8227a7492af5ccfead3d8ab435d/src/cdumay_rest_client/tracing.py#L43-L53 |
cdumay/cdumay-rest-client | src/cdumay_rest_client/tracing.py | RESTClientRequestSpan.extract_tags | def extract_tags(cls, obj):
""" Extract tags from the given object
:param Any obj: Object to use as context
:return: Tags to add on span
:rtype: dict
"""
return dict(
[("request.{}".format(attr), obj.get(attr, None)) for attr in
cls.TAGS]
... | python | def extract_tags(cls, obj):
""" Extract tags from the given object
:param Any obj: Object to use as context
:return: Tags to add on span
:rtype: dict
"""
return dict(
[("request.{}".format(attr), obj.get(attr, None)) for attr in
cls.TAGS]
... | [
"def",
"extract_tags",
"(",
"cls",
",",
"obj",
")",
":",
"return",
"dict",
"(",
"[",
"(",
"\"request.{}\"",
".",
"format",
"(",
"attr",
")",
",",
"obj",
".",
"get",
"(",
"attr",
",",
"None",
")",
")",
"for",
"attr",
"in",
"cls",
".",
"TAGS",
"]",... | Extract tags from the given object
:param Any obj: Object to use as context
:return: Tags to add on span
:rtype: dict | [
"Extract",
"tags",
"from",
"the",
"given",
"object"
] | train | https://github.com/cdumay/cdumay-rest-client/blob/bca34d45748cb8227a7492af5ccfead3d8ab435d/src/cdumay_rest_client/tracing.py#L56-L66 |
rosenbrockc/ci | pyci/msg.py | vms | def vms(message, level=1):
"""Writes the specified message *only* if verbose output is enabled."""
if verbose is not None and verbose != False:
if isinstance(verbose, bool) or (isinstance(verbose, int) and level <= verbose):
std(message) | python | def vms(message, level=1):
"""Writes the specified message *only* if verbose output is enabled."""
if verbose is not None and verbose != False:
if isinstance(verbose, bool) or (isinstance(verbose, int) and level <= verbose):
std(message) | [
"def",
"vms",
"(",
"message",
",",
"level",
"=",
"1",
")",
":",
"if",
"verbose",
"is",
"not",
"None",
"and",
"verbose",
"!=",
"False",
":",
"if",
"isinstance",
"(",
"verbose",
",",
"bool",
")",
"or",
"(",
"isinstance",
"(",
"verbose",
",",
"int",
"... | Writes the specified message *only* if verbose output is enabled. | [
"Writes",
"the",
"specified",
"message",
"*",
"only",
"*",
"if",
"verbose",
"output",
"is",
"enabled",
"."
] | train | https://github.com/rosenbrockc/ci/blob/4d5a60291424a83124d1d962d17fb4c7718cde2b/pyci/msg.py#L74-L78 |
caseyjlaw/sdmreader | sdmreader/sdmreader.py | read_bdf | def read_bdf(sdmpath, scan, nskip=0, readints=0, writebdfpkl=False, bdfdir=None):
""" Reads given range of integrations from sdm of given scan.
Uses BDFData object to read.
readints=0 will read all of bdf (skipping nskip).
Option to write pkl to store bdf info for faster parse next time.
"""
... | python | def read_bdf(sdmpath, scan, nskip=0, readints=0, writebdfpkl=False, bdfdir=None):
""" Reads given range of integrations from sdm of given scan.
Uses BDFData object to read.
readints=0 will read all of bdf (skipping nskip).
Option to write pkl to store bdf info for faster parse next time.
"""
... | [
"def",
"read_bdf",
"(",
"sdmpath",
",",
"scan",
",",
"nskip",
"=",
"0",
",",
"readints",
"=",
"0",
",",
"writebdfpkl",
"=",
"False",
",",
"bdfdir",
"=",
"None",
")",
":",
"assert",
"os",
".",
"path",
".",
"exists",
"(",
"sdmpath",
")",
",",
"'sdmpa... | Reads given range of integrations from sdm of given scan.
Uses BDFData object to read.
readints=0 will read all of bdf (skipping nskip).
Option to write pkl to store bdf info for faster parse next time. | [
"Reads",
"given",
"range",
"of",
"integrations",
"from",
"sdm",
"of",
"given",
"scan",
".",
"Uses",
"BDFData",
"object",
"to",
"read",
".",
"readints",
"=",
"0",
"will",
"read",
"all",
"of",
"bdf",
"(",
"skipping",
"nskip",
")",
".",
"Option",
"to",
"w... | train | https://github.com/caseyjlaw/sdmreader/blob/b6c3498f1915138727819715ee00d2c46353382d/sdmreader/sdmreader.py#L27-L60 |
caseyjlaw/sdmreader | sdmreader/sdmreader.py | calc_uvw | def calc_uvw(sdmfile, scan=0, datetime=0, radec=()):
""" Calculates and returns uvw in meters for a given SDM, time, and pointing direction.
sdmfile is path to sdm directory that includes "Station.xml" file.
scan is scan number defined by observatory.
datetime is time (as string) to calculate uvw (f... | python | def calc_uvw(sdmfile, scan=0, datetime=0, radec=()):
""" Calculates and returns uvw in meters for a given SDM, time, and pointing direction.
sdmfile is path to sdm directory that includes "Station.xml" file.
scan is scan number defined by observatory.
datetime is time (as string) to calculate uvw (f... | [
"def",
"calc_uvw",
"(",
"sdmfile",
",",
"scan",
"=",
"0",
",",
"datetime",
"=",
"0",
",",
"radec",
"=",
"(",
")",
")",
":",
"# set up CASA tools\r",
"try",
":",
"import",
"casautil",
"except",
"ImportError",
":",
"try",
":",
"import",
"pwkit",
".",
"en... | Calculates and returns uvw in meters for a given SDM, time, and pointing direction.
sdmfile is path to sdm directory that includes "Station.xml" file.
scan is scan number defined by observatory.
datetime is time (as string) to calculate uvw (format: '2014/09/03/08:33:04.20')
radec is (ra,dec) as tup... | [
"Calculates",
"and",
"returns",
"uvw",
"in",
"meters",
"for",
"a",
"given",
"SDM",
"time",
"and",
"pointing",
"direction",
".",
"sdmfile",
"is",
"path",
"to",
"sdm",
"directory",
"that",
"includes",
"Station",
".",
"xml",
"file",
".",
"scan",
"is",
"scan",... | train | https://github.com/caseyjlaw/sdmreader/blob/b6c3498f1915138727819715ee00d2c46353382d/sdmreader/sdmreader.py#L62-L158 |
caseyjlaw/sdmreader | sdmreader/sdmreader.py | read_metadata | def read_metadata(sdmfile, scan=0, bdfdir=None):
""" Parses XML files to get scan and source information.
Returns tuple of dicts (scan, source).
bdfdir is optional location to look for bdfs, will try that first, then ASDMBinary subdirectory.
bdfstr in scan dict helps find BDFs with read_bdf (with sp... | python | def read_metadata(sdmfile, scan=0, bdfdir=None):
""" Parses XML files to get scan and source information.
Returns tuple of dicts (scan, source).
bdfdir is optional location to look for bdfs, will try that first, then ASDMBinary subdirectory.
bdfstr in scan dict helps find BDFs with read_bdf (with sp... | [
"def",
"read_metadata",
"(",
"sdmfile",
",",
"scan",
"=",
"0",
",",
"bdfdir",
"=",
"None",
")",
":",
"sdmfile",
"=",
"sdmfile",
".",
"rstrip",
"(",
"'/'",
")",
"assert",
"os",
".",
"path",
".",
"exists",
"(",
"sdmfile",
")",
",",
"'Could not find sdmfi... | Parses XML files to get scan and source information.
Returns tuple of dicts (scan, source).
bdfdir is optional location to look for bdfs, will try that first, then ASDMBinary subdirectory.
bdfstr in scan dict helps find BDFs with read_bdf (with special behavior for prearchive data.
Optional arg scan... | [
"Parses",
"XML",
"files",
"to",
"get",
"scan",
"and",
"source",
"information",
".",
"Returns",
"tuple",
"of",
"dicts",
"(",
"scan",
"source",
")",
".",
"bdfdir",
"is",
"optional",
"location",
"to",
"look",
"for",
"bdfs",
"will",
"try",
"that",
"first",
"... | train | https://github.com/caseyjlaw/sdmreader/blob/b6c3498f1915138727819715ee00d2c46353382d/sdmreader/sdmreader.py#L160-L264 |
caseyjlaw/sdmreader | sdmreader/sdmreader.py | BDFData.parse | def parse(self):
"""wrapper for original parse function. will read pkl with bdf info, if available."""
if os.path.exists(self.pklname): # check for pkl with binary info
logger.info('Found bdf pkl file %s. Loading...' % (self.pklname))
try:
with open(... | python | def parse(self):
"""wrapper for original parse function. will read pkl with bdf info, if available."""
if os.path.exists(self.pklname): # check for pkl with binary info
logger.info('Found bdf pkl file %s. Loading...' % (self.pklname))
try:
with open(... | [
"def",
"parse",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"pklname",
")",
":",
"# check for pkl with binary info\r",
"logger",
".",
"info",
"(",
"'Found bdf pkl file %s. Loading...'",
"%",
"(",
"self",
".",
"pklname",
"... | wrapper for original parse function. will read pkl with bdf info, if available. | [
"wrapper",
"for",
"original",
"parse",
"function",
".",
"will",
"read",
"pkl",
"with",
"bdf",
"info",
"if",
"available",
"."
] | train | https://github.com/caseyjlaw/sdmreader/blob/b6c3498f1915138727819715ee00d2c46353382d/sdmreader/sdmreader.py#L331-L349 |
caseyjlaw/sdmreader | sdmreader/sdmreader.py | BDFData._parse | def _parse (self):
"""Parse the BDF mime structure and record the locations of the binary
blobs. Sets up various data fields in the BDFData object."""
feedparser = FeedParser (Message)
binarychunks = {}
sizeinfo = None
headxml = None
self.fp.seek (0, 0)
... | python | def _parse (self):
"""Parse the BDF mime structure and record the locations of the binary
blobs. Sets up various data fields in the BDFData object."""
feedparser = FeedParser (Message)
binarychunks = {}
sizeinfo = None
headxml = None
self.fp.seek (0, 0)
... | [
"def",
"_parse",
"(",
"self",
")",
":",
"feedparser",
"=",
"FeedParser",
"(",
"Message",
")",
"binarychunks",
"=",
"{",
"}",
"sizeinfo",
"=",
"None",
"headxml",
"=",
"None",
"self",
".",
"fp",
".",
"seek",
"(",
"0",
",",
"0",
")",
"while",
"True",
... | Parse the BDF mime structure and record the locations of the binary
blobs. Sets up various data fields in the BDFData object. | [
"Parse",
"the",
"BDF",
"mime",
"structure",
"and",
"record",
"the",
"locations",
"of",
"the",
"binary",
"blobs",
".",
"Sets",
"up",
"various",
"data",
"fields",
"in",
"the",
"BDFData",
"object",
"."
] | train | https://github.com/caseyjlaw/sdmreader/blob/b6c3498f1915138727819715ee00d2c46353382d/sdmreader/sdmreader.py#L351-L440 |
caseyjlaw/sdmreader | sdmreader/sdmreader.py | BDFData.get_data | def get_data (self, datakind, integnum):
"""Given an integration number (0 <= integnum < self.n_integrations) and a
data kind ('crossData.bin', 'autoData.bin'), memory-map the corresponding data
and return a wrapping numpy array."""
if integnum < 0 or integnum >= self.n_integration... | python | def get_data (self, datakind, integnum):
"""Given an integration number (0 <= integnum < self.n_integrations) and a
data kind ('crossData.bin', 'autoData.bin'), memory-map the corresponding data
and return a wrapping numpy array."""
if integnum < 0 or integnum >= self.n_integration... | [
"def",
"get_data",
"(",
"self",
",",
"datakind",
",",
"integnum",
")",
":",
"if",
"integnum",
"<",
"0",
"or",
"integnum",
">=",
"self",
".",
"n_integrations",
":",
"raise",
"ValueError",
"(",
"'illegal integration number %d'",
"%",
"integnum",
")",
"size",
"... | Given an integration number (0 <= integnum < self.n_integrations) and a
data kind ('crossData.bin', 'autoData.bin'), memory-map the corresponding data
and return a wrapping numpy array. | [
"Given",
"an",
"integration",
"number",
"(",
"0",
"<",
"=",
"integnum",
"<",
"self",
".",
"n_integrations",
")",
"and",
"a",
"data",
"kind",
"(",
"crossData",
".",
"bin",
"autoData",
".",
"bin",
")",
"memory",
"-",
"map",
"the",
"corresponding",
"data",
... | train | https://github.com/caseyjlaw/sdmreader/blob/b6c3498f1915138727819715ee00d2c46353382d/sdmreader/sdmreader.py#L442-L467 |
caseyjlaw/sdmreader | sdmreader/sdmreader.py | BDFData.calc_intsize | def calc_intsize(self):
""" Calculates the size of an integration (cross + auto) in bytes
"""
# assume first cross blob starts after headxml and second is one int of bytes later
for k in self.binarychunks.iterkeys():
if int(k.split('/')[3]) == 1 and 'cross' in k.split(... | python | def calc_intsize(self):
""" Calculates the size of an integration (cross + auto) in bytes
"""
# assume first cross blob starts after headxml and second is one int of bytes later
for k in self.binarychunks.iterkeys():
if int(k.split('/')[3]) == 1 and 'cross' in k.split(... | [
"def",
"calc_intsize",
"(",
"self",
")",
":",
"# assume first cross blob starts after headxml and second is one int of bytes later\r",
"for",
"k",
"in",
"self",
".",
"binarychunks",
".",
"iterkeys",
"(",
")",
":",
"if",
"int",
"(",
"k",
".",
"split",
"(",
"'/'",
"... | Calculates the size of an integration (cross + auto) in bytes | [
"Calculates",
"the",
"size",
"of",
"an",
"integration",
"(",
"cross",
"+",
"auto",
")",
"in",
"bytes"
] | train | https://github.com/caseyjlaw/sdmreader/blob/b6c3498f1915138727819715ee00d2c46353382d/sdmreader/sdmreader.py#L469-L483 |
Bystroushaak/pyDHTMLParser | src/dhtmlparser/htmlelement/html_element.py | HTMLElement.toString | def toString(self):
"""
Returns almost original string.
If you want prettified string, try :meth:`.prettify`.
Returns:
str: Complete representation of the element with childs, endtag \
and so on.
"""
output = ""
if self.childs or se... | python | def toString(self):
"""
Returns almost original string.
If you want prettified string, try :meth:`.prettify`.
Returns:
str: Complete representation of the element with childs, endtag \
and so on.
"""
output = ""
if self.childs or se... | [
"def",
"toString",
"(",
"self",
")",
":",
"output",
"=",
"\"\"",
"if",
"self",
".",
"childs",
"or",
"self",
".",
"isOpeningTag",
"(",
")",
":",
"output",
"+=",
"self",
".",
"tagToString",
"(",
")",
"for",
"c",
"in",
"self",
".",
"childs",
":",
"out... | Returns almost original string.
If you want prettified string, try :meth:`.prettify`.
Returns:
str: Complete representation of the element with childs, endtag \
and so on. | [
"Returns",
"almost",
"original",
"string",
"."
] | train | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/htmlelement/html_element.py#L20-L44 |
Bystroushaak/pyDHTMLParser | src/dhtmlparser/htmlelement/html_element.py | HTMLElement.getContent | def getContent(self):
"""
Returns:
str: Content of tag (everything between `opener` and `endtag`).
"""
if not self.isTag() and self._element:
return self._element
if not self.childs:
return ""
output = ""
for c in self.childs:... | python | def getContent(self):
"""
Returns:
str: Content of tag (everything between `opener` and `endtag`).
"""
if not self.isTag() and self._element:
return self._element
if not self.childs:
return ""
output = ""
for c in self.childs:... | [
"def",
"getContent",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"isTag",
"(",
")",
"and",
"self",
".",
"_element",
":",
"return",
"self",
".",
"_element",
"if",
"not",
"self",
".",
"childs",
":",
"return",
"\"\"",
"output",
"=",
"\"\"",
"for",
... | Returns:
str: Content of tag (everything between `opener` and `endtag`). | [
"Returns",
":",
"str",
":",
"Content",
"of",
"tag",
"(",
"everything",
"between",
"opener",
"and",
"endtag",
")",
"."
] | train | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/htmlelement/html_element.py#L46-L65 |
Bystroushaak/pyDHTMLParser | src/dhtmlparser/htmlelement/html_element.py | HTMLElement.prettify | def prettify(self, depth=0, separator=" ", last=True, pre=False,
inline=False):
"""
Same as :meth:`toString`, but returns prettified element with content.
Note:
This method is partially broken, and can sometimes create
unexpected results.
Retur... | python | def prettify(self, depth=0, separator=" ", last=True, pre=False,
inline=False):
"""
Same as :meth:`toString`, but returns prettified element with content.
Note:
This method is partially broken, and can sometimes create
unexpected results.
Retur... | [
"def",
"prettify",
"(",
"self",
",",
"depth",
"=",
"0",
",",
"separator",
"=",
"\" \"",
",",
"last",
"=",
"True",
",",
"pre",
"=",
"False",
",",
"inline",
"=",
"False",
")",
":",
"output",
"=",
"\"\"",
"if",
"self",
".",
"getTagName",
"(",
")",
... | Same as :meth:`toString`, but returns prettified element with content.
Note:
This method is partially broken, and can sometimes create
unexpected results.
Returns:
str: Prettified string. | [
"Same",
"as",
":",
"meth",
":",
"toString",
"but",
"returns",
"prettified",
"element",
"with",
"content",
"."
] | train | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/htmlelement/html_element.py#L67-L131 |
Bystroushaak/pyDHTMLParser | src/dhtmlparser/htmlelement/html_element.py | HTMLElement.replaceWith | def replaceWith(self, el):
"""
Replace value in this element with values from `el`.
This useful when you don't want change all references to object.
Args:
el (obj): :class:`HTMLElement` instance.
"""
self.childs = el.childs
self.params = el.params
... | python | def replaceWith(self, el):
"""
Replace value in this element with values from `el`.
This useful when you don't want change all references to object.
Args:
el (obj): :class:`HTMLElement` instance.
"""
self.childs = el.childs
self.params = el.params
... | [
"def",
"replaceWith",
"(",
"self",
",",
"el",
")",
":",
"self",
".",
"childs",
"=",
"el",
".",
"childs",
"self",
".",
"params",
"=",
"el",
".",
"params",
"self",
".",
"endtag",
"=",
"el",
".",
"endtag",
"self",
".",
"openertag",
"=",
"el",
".",
"... | Replace value in this element with values from `el`.
This useful when you don't want change all references to object.
Args:
el (obj): :class:`HTMLElement` instance. | [
"Replace",
"value",
"in",
"this",
"element",
"with",
"values",
"from",
"el",
"."
] | train | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/htmlelement/html_element.py#L133-L153 |
Bystroushaak/pyDHTMLParser | src/dhtmlparser/htmlelement/html_element.py | HTMLElement.removeChild | def removeChild(self, child, end_tag_too=True):
"""
Remove subelement (`child`) specified by reference.
Note:
This can't be used for removing subelements by value! If you want
to do such thing, try::
for e in dom.find("value"):
dom.re... | python | def removeChild(self, child, end_tag_too=True):
"""
Remove subelement (`child`) specified by reference.
Note:
This can't be used for removing subelements by value! If you want
to do such thing, try::
for e in dom.find("value"):
dom.re... | [
"def",
"removeChild",
"(",
"self",
",",
"child",
",",
"end_tag_too",
"=",
"True",
")",
":",
"# if there are multiple childs, remove them",
"if",
"_is_iterable",
"(",
"child",
")",
":",
"for",
"x",
"in",
"child",
":",
"self",
".",
"removeChild",
"(",
"child",
... | Remove subelement (`child`) specified by reference.
Note:
This can't be used for removing subelements by value! If you want
to do such thing, try::
for e in dom.find("value"):
dom.removeChild(e)
Args:
child (obj): :class:`HTMLEle... | [
"Remove",
"subelement",
"(",
"child",
")",
"specified",
"by",
"reference",
"."
] | train | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/htmlelement/html_element.py#L155-L192 |
darkowlzz/pokemonNames | pokemonNames/pokemonNames.py | PokemonNames.get_name | def get_name(self, key):
'''Return a name for the given key
Argument:
key -- Pokemon number id (int)
'''
try:
return self.nameDict[key]
except IndexError as e:
print 'IndexError {0}: {1}'.format(e.errno, e.strerror) | python | def get_name(self, key):
'''Return a name for the given key
Argument:
key -- Pokemon number id (int)
'''
try:
return self.nameDict[key]
except IndexError as e:
print 'IndexError {0}: {1}'.format(e.errno, e.strerror) | [
"def",
"get_name",
"(",
"self",
",",
"key",
")",
":",
"try",
":",
"return",
"self",
".",
"nameDict",
"[",
"key",
"]",
"except",
"IndexError",
"as",
"e",
":",
"print",
"'IndexError {0}: {1}'",
".",
"format",
"(",
"e",
".",
"errno",
",",
"e",
".",
"str... | Return a name for the given key
Argument:
key -- Pokemon number id (int) | [
"Return",
"a",
"name",
"for",
"the",
"given",
"key",
"Argument",
":",
"key",
"--",
"Pokemon",
"number",
"id",
"(",
"int",
")"
] | train | https://github.com/darkowlzz/pokemonNames/blob/fe4b9cf2108115c8a090193247413dcb5416fcff/pokemonNames/pokemonNames.py#L59-L67 |
darkowlzz/pokemonNames | pokemonNames/pokemonNames.py | PokemonNames.append_to_list | def append_to_list(self, source, start=None, hasIndex=False):
'''Appends new list to self.nameDict
Argument:
source -- source of new name list (filename or list)
start -- starting index of new list
hasIndex -- the file is already indexed
'''
nfy = Numberify()
... | python | def append_to_list(self, source, start=None, hasIndex=False):
'''Appends new list to self.nameDict
Argument:
source -- source of new name list (filename or list)
start -- starting index of new list
hasIndex -- the file is already indexed
'''
nfy = Numberify()
... | [
"def",
"append_to_list",
"(",
"self",
",",
"source",
",",
"start",
"=",
"None",
",",
"hasIndex",
"=",
"False",
")",
":",
"nfy",
"=",
"Numberify",
"(",
")",
"try",
":",
"if",
"start",
"is",
"None",
":",
"if",
"type",
"(",
"source",
")",
"is",
"str",... | Appends new list to self.nameDict
Argument:
source -- source of new name list (filename or list)
start -- starting index of new list
hasIndex -- the file is already indexed | [
"Appends",
"new",
"list",
"to",
"self",
".",
"nameDict",
"Argument",
":",
"source",
"--",
"source",
"of",
"new",
"name",
"list",
"(",
"filename",
"or",
"list",
")",
"start",
"--",
"starting",
"index",
"of",
"new",
"list",
"hasIndex",
"--",
"the",
"file",... | train | https://github.com/darkowlzz/pokemonNames/blob/fe4b9cf2108115c8a090193247413dcb5416fcff/pokemonNames/pokemonNames.py#L69-L90 |
renzon/gaepagseguro | gaepagseguro/save_commands.py | SaveItemCmd.handle_previous | def handle_previous(self, command):
"""
Method to generate item from a ItemForm. The form must be exposed on form attribute
@param command: a command tha expose data through form attributte
"""
self.result = command.items
self._to_commit = self.result | python | def handle_previous(self, command):
"""
Method to generate item from a ItemForm. The form must be exposed on form attribute
@param command: a command tha expose data through form attributte
"""
self.result = command.items
self._to_commit = self.result | [
"def",
"handle_previous",
"(",
"self",
",",
"command",
")",
":",
"self",
".",
"result",
"=",
"command",
".",
"items",
"self",
".",
"_to_commit",
"=",
"self",
".",
"result"
] | Method to generate item from a ItemForm. The form must be exposed on form attribute
@param command: a command tha expose data through form attributte | [
"Method",
"to",
"generate",
"item",
"from",
"a",
"ItemForm",
".",
"The",
"form",
"must",
"be",
"exposed",
"on",
"form",
"attribute"
] | train | https://github.com/renzon/gaepagseguro/blob/c88f00580c380ff5b35d873311d6c786fa1f29d2/gaepagseguro/save_commands.py#L11-L17 |
ErikBjare/pyzenobase | examples/upload_lifelogger_spreadsheet/main.py | Lifelogger_to_Zenobase.get_dates | def get_dates(raw_table) -> "list of dates":
"""
Goes through the first column of input table and
returns the first sequence of dates it finds.
"""
dates = []
found_first = False
for i, dstr in enumerate([raw_table[i][0] for i in range(0, len(raw_table))])... | python | def get_dates(raw_table) -> "list of dates":
"""
Goes through the first column of input table and
returns the first sequence of dates it finds.
"""
dates = []
found_first = False
for i, dstr in enumerate([raw_table[i][0] for i in range(0, len(raw_table))])... | [
"def",
"get_dates",
"(",
"raw_table",
")",
"->",
"\"list of dates\"",
":",
"dates",
"=",
"[",
"]",
"found_first",
"=",
"False",
"for",
"i",
",",
"dstr",
"in",
"enumerate",
"(",
"[",
"raw_table",
"[",
"i",
"]",
"[",
"0",
"]",
"for",
"i",
"in",
"range"... | Goes through the first column of input table and
returns the first sequence of dates it finds. | [
"Goes",
"through",
"the",
"first",
"column",
"of",
"input",
"table",
"and",
"returns",
"the",
"first",
"sequence",
"of",
"dates",
"it",
"finds",
"."
] | train | https://github.com/ErikBjare/pyzenobase/blob/eb0572c7441a350bf5578bc5287f3be53d32ea19/examples/upload_lifelogger_spreadsheet/main.py#L63-L87 |
ErikBjare/pyzenobase | examples/upload_lifelogger_spreadsheet/main.py | Lifelogger_to_Zenobase.get_main | def get_main(self) -> 'table[category: str][label: str][date: date]':
"""
Returns a table with the above typesignature
"""
raw_table = self.get_raw_table("M")
categories = raw_table[0]
labels = raw_table[1]
dates = self.get_dates(raw_table)
def next_... | python | def get_main(self) -> 'table[category: str][label: str][date: date]':
"""
Returns a table with the above typesignature
"""
raw_table = self.get_raw_table("M")
categories = raw_table[0]
labels = raw_table[1]
dates = self.get_dates(raw_table)
def next_... | [
"def",
"get_main",
"(",
"self",
")",
"->",
"'table[category: str][label: str][date: date]'",
":",
"raw_table",
"=",
"self",
".",
"get_raw_table",
"(",
"\"M\"",
")",
"categories",
"=",
"raw_table",
"[",
"0",
"]",
"labels",
"=",
"raw_table",
"[",
"1",
"]",
"date... | Returns a table with the above typesignature | [
"Returns",
"a",
"table",
"with",
"the",
"above",
"typesignature"
] | train | https://github.com/ErikBjare/pyzenobase/blob/eb0572c7441a350bf5578bc5287f3be53d32ea19/examples/upload_lifelogger_spreadsheet/main.py#L89-L130 |
funkybob/antfarm | antfarm/response.py | Response.build_headers | def build_headers(self):
'''
Return the list of headers as two-tuples
'''
if not 'Content-Type' in self.headers:
content_type = self.content_type
if self.encoding != DEFAULT_ENCODING:
content_type += '; charset=%s' % self.encoding
self.... | python | def build_headers(self):
'''
Return the list of headers as two-tuples
'''
if not 'Content-Type' in self.headers:
content_type = self.content_type
if self.encoding != DEFAULT_ENCODING:
content_type += '; charset=%s' % self.encoding
self.... | [
"def",
"build_headers",
"(",
"self",
")",
":",
"if",
"not",
"'Content-Type'",
"in",
"self",
".",
"headers",
":",
"content_type",
"=",
"self",
".",
"content_type",
"if",
"self",
".",
"encoding",
"!=",
"DEFAULT_ENCODING",
":",
"content_type",
"+=",
"'; charset=%... | Return the list of headers as two-tuples | [
"Return",
"the",
"list",
"of",
"headers",
"as",
"two",
"-",
"tuples"
] | train | https://github.com/funkybob/antfarm/blob/40a7cc450eba09a280b7bc8f7c68a807b0177c62/antfarm/response.py#L90-L106 |
funkybob/antfarm | antfarm/response.py | Response.add_cookie | def add_cookie(self, key, value, **attrs):
'''
Finer control over cookies. Allow specifying an Morsel arguments.
'''
if attrs:
c = Morsel()
c.set(key, value, **attrs)
self.cookies[key] = c
else:
self.cookies[key] = value | python | def add_cookie(self, key, value, **attrs):
'''
Finer control over cookies. Allow specifying an Morsel arguments.
'''
if attrs:
c = Morsel()
c.set(key, value, **attrs)
self.cookies[key] = c
else:
self.cookies[key] = value | [
"def",
"add_cookie",
"(",
"self",
",",
"key",
",",
"value",
",",
"*",
"*",
"attrs",
")",
":",
"if",
"attrs",
":",
"c",
"=",
"Morsel",
"(",
")",
"c",
".",
"set",
"(",
"key",
",",
"value",
",",
"*",
"*",
"attrs",
")",
"self",
".",
"cookies",
"[... | Finer control over cookies. Allow specifying an Morsel arguments. | [
"Finer",
"control",
"over",
"cookies",
".",
"Allow",
"specifying",
"an",
"Morsel",
"arguments",
"."
] | train | https://github.com/funkybob/antfarm/blob/40a7cc450eba09a280b7bc8f7c68a807b0177c62/antfarm/response.py#L108-L117 |
funkybob/antfarm | antfarm/response.py | Response.status | def status(self):
'''Allow custom status messages'''
message = self.status_message
if message is None:
message = STATUS[self.status_code]
return '%s %s' % (self.status_code, message) | python | def status(self):
'''Allow custom status messages'''
message = self.status_message
if message is None:
message = STATUS[self.status_code]
return '%s %s' % (self.status_code, message) | [
"def",
"status",
"(",
"self",
")",
":",
"message",
"=",
"self",
".",
"status_message",
"if",
"message",
"is",
"None",
":",
"message",
"=",
"STATUS",
"[",
"self",
".",
"status_code",
"]",
"return",
"'%s %s'",
"%",
"(",
"self",
".",
"status_code",
",",
"... | Allow custom status messages | [
"Allow",
"custom",
"status",
"messages"
] | train | https://github.com/funkybob/antfarm/blob/40a7cc450eba09a280b7bc8f7c68a807b0177c62/antfarm/response.py#L120-L125 |
littlemo/moear-api-common | moear_api_common/utils/img.py | rescale_image | def rescale_image(
data, maxsizeb=4000000, dimen=None,
png2jpg=False, graying=True, reduceto=(600, 800)):
'''
若 ``png2jpg`` 为 ``True`` 则将图片转换为 ``JPEG`` 格式,所有透明像素被设置为
*白色* 。确保结果图片尺寸小于 ``maxsizeb`` 的约束限制。
如果 ``dimen`` 不为空,则生成一个相应约束的缩略图。依据 ``dimen`` 的类型,设置约束为
``width=dimen, height=dime... | python | def rescale_image(
data, maxsizeb=4000000, dimen=None,
png2jpg=False, graying=True, reduceto=(600, 800)):
'''
若 ``png2jpg`` 为 ``True`` 则将图片转换为 ``JPEG`` 格式,所有透明像素被设置为
*白色* 。确保结果图片尺寸小于 ``maxsizeb`` 的约束限制。
如果 ``dimen`` 不为空,则生成一个相应约束的缩略图。依据 ``dimen`` 的类型,设置约束为
``width=dimen, height=dime... | [
"def",
"rescale_image",
"(",
"data",
",",
"maxsizeb",
"=",
"4000000",
",",
"dimen",
"=",
"None",
",",
"png2jpg",
"=",
"False",
",",
"graying",
"=",
"True",
",",
"reduceto",
"=",
"(",
"600",
",",
"800",
")",
")",
":",
"if",
"not",
"isinstance",
"(",
... | 若 ``png2jpg`` 为 ``True`` 则将图片转换为 ``JPEG`` 格式,所有透明像素被设置为
*白色* 。确保结果图片尺寸小于 ``maxsizeb`` 的约束限制。
如果 ``dimen`` 不为空,则生成一个相应约束的缩略图。依据 ``dimen`` 的类型,设置约束为
``width=dimen, height=dimen`` 或者 ``width, height = dimen``
:param data: 原始图片字节数据
:type data: bytes or io.BytesIO
:param int maxsizeb: 文件大小约束,单位:字节
... | [
"若",
"png2jpg",
"为",
"True",
"则将图片转换为",
"JPEG",
"格式,所有透明像素被设置为",
"*",
"白色",
"*",
"。确保结果图片尺寸小于",
"maxsizeb",
"的约束限制。"
] | train | https://github.com/littlemo/moear-api-common/blob/2a89a052d92592dd8e67bd50ec2fadc0219ac5d0/moear_api_common/utils/img.py#L5-L64 |
littlemo/moear-api-common | moear_api_common/utils/img.py | gray_image | def gray_image(data):
'''
灰度化图片
将传入的图片数据转换为灰度图后返回
:param data bytes: 图片字节数据,可通过以 ``rb`` 模式读取图片文件获得
:return: 处理后的图片字节数据,可直接以 ``wb`` 模式输出到文件中
:rtype: bytes
'''
if not isinstance(data, BytesIO):
data = BytesIO(data)
img = Image.open(data)
fmt = img.format
if img.mode !... | python | def gray_image(data):
'''
灰度化图片
将传入的图片数据转换为灰度图后返回
:param data bytes: 图片字节数据,可通过以 ``rb`` 模式读取图片文件获得
:return: 处理后的图片字节数据,可直接以 ``wb`` 模式输出到文件中
:rtype: bytes
'''
if not isinstance(data, BytesIO):
data = BytesIO(data)
img = Image.open(data)
fmt = img.format
if img.mode !... | [
"def",
"gray_image",
"(",
"data",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"BytesIO",
")",
":",
"data",
"=",
"BytesIO",
"(",
"data",
")",
"img",
"=",
"Image",
".",
"open",
"(",
"data",
")",
"fmt",
"=",
"img",
".",
"format",
"if",
"i... | 灰度化图片
将传入的图片数据转换为灰度图后返回
:param data bytes: 图片字节数据,可通过以 ``rb`` 模式读取图片文件获得
:return: 处理后的图片字节数据,可直接以 ``wb`` 模式输出到文件中
:rtype: bytes | [
"灰度化图片"
] | train | https://github.com/littlemo/moear-api-common/blob/2a89a052d92592dd8e67bd50ec2fadc0219ac5d0/moear_api_common/utils/img.py#L67-L85 |
jambonrose/django-decorator-plus | decorator_plus/version.py | get_git_changeset | def get_git_changeset():
"""Get git identifier; taken from Django project."""
git_log = Popen(
'git log --pretty=format:%ct --quiet -1 HEAD',
stdout=PIPE, stderr=PIPE, shell=True, universal_newlines=True)
timestamp = git_log.communicate()[0]
try:
timestamp = datetime.utcfromtimes... | python | def get_git_changeset():
"""Get git identifier; taken from Django project."""
git_log = Popen(
'git log --pretty=format:%ct --quiet -1 HEAD',
stdout=PIPE, stderr=PIPE, shell=True, universal_newlines=True)
timestamp = git_log.communicate()[0]
try:
timestamp = datetime.utcfromtimes... | [
"def",
"get_git_changeset",
"(",
")",
":",
"git_log",
"=",
"Popen",
"(",
"'git log --pretty=format:%ct --quiet -1 HEAD'",
",",
"stdout",
"=",
"PIPE",
",",
"stderr",
"=",
"PIPE",
",",
"shell",
"=",
"True",
",",
"universal_newlines",
"=",
"True",
")",
"timestamp",... | Get git identifier; taken from Django project. | [
"Get",
"git",
"identifier",
";",
"taken",
"from",
"Django",
"project",
"."
] | train | https://github.com/jambonrose/django-decorator-plus/blob/2039ef7a4b5f8abb29e455e8218c207fcae24e2c/decorator_plus/version.py#L25-L35 |
jambonrose/django-decorator-plus | decorator_plus/version.py | get_version | def get_version(version_tuple):
"""Convert 4-tuple into a PEP 440 compliant string."""
if version_tuple[3] == FINAL and version_tuple[4] != 0:
raise Exception(
'Project version number misconfigured:\n'
' version may not be final and have segment number.')
if version_tuple[... | python | def get_version(version_tuple):
"""Convert 4-tuple into a PEP 440 compliant string."""
if version_tuple[3] == FINAL and version_tuple[4] != 0:
raise Exception(
'Project version number misconfigured:\n'
' version may not be final and have segment number.')
if version_tuple[... | [
"def",
"get_version",
"(",
"version_tuple",
")",
":",
"if",
"version_tuple",
"[",
"3",
"]",
"==",
"FINAL",
"and",
"version_tuple",
"[",
"4",
"]",
"!=",
"0",
":",
"raise",
"Exception",
"(",
"'Project version number misconfigured:\\n'",
"' version may not be final a... | Convert 4-tuple into a PEP 440 compliant string. | [
"Convert",
"4",
"-",
"tuple",
"into",
"a",
"PEP",
"440",
"compliant",
"string",
"."
] | train | https://github.com/jambonrose/django-decorator-plus/blob/2039ef7a4b5f8abb29e455e8218c207fcae24e2c/decorator_plus/version.py#L38-L72 |
Meseira/subordinate | subordinate/idmap.py | IdMap.append | def append(self, name):
"""If name is not in the map, append it with an empty id range set."""
if not isinstance(name, str):
raise TypeError(
"argument 'name' must be a string, not {}".format(
name.__class__.__name__
)
... | python | def append(self, name):
"""If name is not in the map, append it with an empty id range set."""
if not isinstance(name, str):
raise TypeError(
"argument 'name' must be a string, not {}".format(
name.__class__.__name__
)
... | [
"def",
"append",
"(",
"self",
",",
"name",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"argument 'name' must be a string, not {}\"",
".",
"format",
"(",
"name",
".",
"__class__",
".",
"__name__",
")",
... | If name is not in the map, append it with an empty id range set. | [
"If",
"name",
"is",
"not",
"in",
"the",
"map",
"append",
"it",
"with",
"an",
"empty",
"id",
"range",
"set",
"."
] | train | https://github.com/Meseira/subordinate/blob/3438df304af3dccc5bd1515231402afa708f1cc3/subordinate/idmap.py#L74-L88 |
Meseira/subordinate | subordinate/idmap.py | IdMap.read_file | def read_file(self, id_file):
"""
Read and parse id data from id_file which must be an iterable
yielding Unicode strings formatted as in '/etc/subuid' or
'/etc/subgid'.
"""
lineno = 0
for line in id_file:
lineno += 1
id_data = line.split('... | python | def read_file(self, id_file):
"""
Read and parse id data from id_file which must be an iterable
yielding Unicode strings formatted as in '/etc/subuid' or
'/etc/subgid'.
"""
lineno = 0
for line in id_file:
lineno += 1
id_data = line.split('... | [
"def",
"read_file",
"(",
"self",
",",
"id_file",
")",
":",
"lineno",
"=",
"0",
"for",
"line",
"in",
"id_file",
":",
"lineno",
"+=",
"1",
"id_data",
"=",
"line",
".",
"split",
"(",
"':'",
")",
"if",
"len",
"(",
"id_data",
")",
"!=",
"3",
":",
"rai... | Read and parse id data from id_file which must be an iterable
yielding Unicode strings formatted as in '/etc/subuid' or
'/etc/subgid'. | [
"Read",
"and",
"parse",
"id",
"data",
"from",
"id_file",
"which",
"must",
"be",
"an",
"iterable",
"yielding",
"Unicode",
"strings",
"formatted",
"as",
"in",
"/",
"etc",
"/",
"subuid",
"or",
"/",
"etc",
"/",
"subgid",
"."
] | train | https://github.com/Meseira/subordinate/blob/3438df304af3dccc5bd1515231402afa708f1cc3/subordinate/idmap.py#L116-L146 |
Meseira/subordinate | subordinate/idmap.py | IdMap.write_string | def write_string(self):
"""
Return a representation of the id map as a string. This string is
properly formatted to be written in '/etc/subuid' or '/etc/subgid'.
"""
map_as_str = []
for name, id_range_set in self.__map.items():
for id_range in id_range_set:
... | python | def write_string(self):
"""
Return a representation of the id map as a string. This string is
properly formatted to be written in '/etc/subuid' or '/etc/subgid'.
"""
map_as_str = []
for name, id_range_set in self.__map.items():
for id_range in id_range_set:
... | [
"def",
"write_string",
"(",
"self",
")",
":",
"map_as_str",
"=",
"[",
"]",
"for",
"name",
",",
"id_range_set",
"in",
"self",
".",
"__map",
".",
"items",
"(",
")",
":",
"for",
"id_range",
"in",
"id_range_set",
":",
"map_as_str",
".",
"append",
"(",
"nam... | Return a representation of the id map as a string. This string is
properly formatted to be written in '/etc/subuid' or '/etc/subgid'. | [
"Return",
"a",
"representation",
"of",
"the",
"id",
"map",
"as",
"a",
"string",
".",
"This",
"string",
"is",
"properly",
"formatted",
"to",
"be",
"written",
"in",
"/",
"etc",
"/",
"subuid",
"or",
"/",
"etc",
"/",
"subgid",
"."
] | train | https://github.com/Meseira/subordinate/blob/3438df304af3dccc5bd1515231402afa708f1cc3/subordinate/idmap.py#L156-L175 |
Meseira/subordinate | subordinate/idmap.py | IdMap.who_has | def who_has(self, subid):
"""Return a list of names who own subid in their id range set."""
answer = []
for name in self.__map:
if subid in self.__map[name] and not name in answer:
answer.append(name)
return answer | python | def who_has(self, subid):
"""Return a list of names who own subid in their id range set."""
answer = []
for name in self.__map:
if subid in self.__map[name] and not name in answer:
answer.append(name)
return answer | [
"def",
"who_has",
"(",
"self",
",",
"subid",
")",
":",
"answer",
"=",
"[",
"]",
"for",
"name",
"in",
"self",
".",
"__map",
":",
"if",
"subid",
"in",
"self",
".",
"__map",
"[",
"name",
"]",
"and",
"not",
"name",
"in",
"answer",
":",
"answer",
".",... | Return a list of names who own subid in their id range set. | [
"Return",
"a",
"list",
"of",
"names",
"who",
"own",
"subid",
"in",
"their",
"id",
"range",
"set",
"."
] | train | https://github.com/Meseira/subordinate/blob/3438df304af3dccc5bd1515231402afa708f1cc3/subordinate/idmap.py#L177-L185 |
fdb/aufmachen | aufmachen/crawler.py | phantomjs_retrieve | def phantomjs_retrieve(url, data=None):
"""Retrieve the given URL using PhantomJS.
PhantomJS will evaluate all scripts and return the HTML after body.onload.
url - The page URL to retrieve
data - The form data. TODO: Currently ignored.
Returns a status code (e.g. 200) and the HTML as a unicod... | python | def phantomjs_retrieve(url, data=None):
"""Retrieve the given URL using PhantomJS.
PhantomJS will evaluate all scripts and return the HTML after body.onload.
url - The page URL to retrieve
data - The form data. TODO: Currently ignored.
Returns a status code (e.g. 200) and the HTML as a unicod... | [
"def",
"phantomjs_retrieve",
"(",
"url",
",",
"data",
"=",
"None",
")",
":",
"range_limit",
"(",
")",
"print",
"\"pGET\"",
",",
"url",
"process",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"'phantomjs'",
",",
"PHANTOM_SCRIPT",
",",
"url",
"]",
",",
"stdo... | Retrieve the given URL using PhantomJS.
PhantomJS will evaluate all scripts and return the HTML after body.onload.
url - The page URL to retrieve
data - The form data. TODO: Currently ignored.
Returns a status code (e.g. 200) and the HTML as a unicode string. | [
"Retrieve",
"the",
"given",
"URL",
"using",
"PhantomJS",
".",
"PhantomJS",
"will",
"evaluate",
"all",
"scripts",
"and",
"return",
"the",
"HTML",
"after",
"body",
".",
"onload",
".",
"url",
"-",
"The",
"page",
"URL",
"to",
"retrieve",
"data",
"-",
"The",
... | train | https://github.com/fdb/aufmachen/blob/f2986a0cf087ac53969f82b84d872e3f1c6986f4/aufmachen/crawler.py#L35-L55 |
fdb/aufmachen | aufmachen/crawler.py | urllib_retrieve | def urllib_retrieve(url, data=None):
"""Retrieve the given URL using Python's built-in urllib.
url - The page URL to retrieve.
data - The form data. If you provide this will use the POST method.
Returns a status code (e.g. 200) and the HTML as a unicode string.
"""
range_limit()
p... | python | def urllib_retrieve(url, data=None):
"""Retrieve the given URL using Python's built-in urllib.
url - The page URL to retrieve.
data - The form data. If you provide this will use the POST method.
Returns a status code (e.g. 200) and the HTML as a unicode string.
"""
range_limit()
p... | [
"def",
"urllib_retrieve",
"(",
"url",
",",
"data",
"=",
"None",
")",
":",
"range_limit",
"(",
")",
"print",
"\"uGET\"",
",",
"url",
"f",
"=",
"urlopen",
"(",
"url",
",",
"data",
")",
"html",
"=",
"f",
".",
"read",
"(",
")",
".",
"decode",
"(",
"'... | Retrieve the given URL using Python's built-in urllib.
url - The page URL to retrieve.
data - The form data. If you provide this will use the POST method.
Returns a status code (e.g. 200) and the HTML as a unicode string. | [
"Retrieve",
"the",
"given",
"URL",
"using",
"Python",
"s",
"built",
"-",
"in",
"urllib",
".",
"url",
"-",
"The",
"page",
"URL",
"to",
"retrieve",
".",
"data",
"-",
"The",
"form",
"data",
".",
"If",
"you",
"provide",
"this",
"will",
"use",
"the",
"POS... | train | https://github.com/fdb/aufmachen/blob/f2986a0cf087ac53969f82b84d872e3f1c6986f4/aufmachen/crawler.py#L57-L69 |
fdb/aufmachen | aufmachen/crawler.py | cache_path_for_url | def cache_path_for_url(url):
"""Return the path where the URL might be cached."""
m = hashlib.md5()
m.update(url)
digest = m.hexdigest()
return os.path.join(CACHE_DIRECTORY, '%s.html' % digest) | python | def cache_path_for_url(url):
"""Return the path where the URL might be cached."""
m = hashlib.md5()
m.update(url)
digest = m.hexdigest()
return os.path.join(CACHE_DIRECTORY, '%s.html' % digest) | [
"def",
"cache_path_for_url",
"(",
"url",
")",
":",
"m",
"=",
"hashlib",
".",
"md5",
"(",
")",
"m",
".",
"update",
"(",
"url",
")",
"digest",
"=",
"m",
".",
"hexdigest",
"(",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"CACHE_DIRECTORY",
","... | Return the path where the URL might be cached. | [
"Return",
"the",
"path",
"where",
"the",
"URL",
"might",
"be",
"cached",
"."
] | train | https://github.com/fdb/aufmachen/blob/f2986a0cf087ac53969f82b84d872e3f1c6986f4/aufmachen/crawler.py#L71-L76 |
fdb/aufmachen | aufmachen/crawler.py | get_url | def get_url(url, data=None, cached=True, cache_key=None, crawler='urllib'):
"""Retrieves the HTML code for a given URL.
If a cached version is not available, uses phantom_retrieve to fetch the page.
data - Additional data that gets passed onto the crawler.
cached - If True, retrieves the URL from the ... | python | def get_url(url, data=None, cached=True, cache_key=None, crawler='urllib'):
"""Retrieves the HTML code for a given URL.
If a cached version is not available, uses phantom_retrieve to fetch the page.
data - Additional data that gets passed onto the crawler.
cached - If True, retrieves the URL from the ... | [
"def",
"get_url",
"(",
"url",
",",
"data",
"=",
"None",
",",
"cached",
"=",
"True",
",",
"cache_key",
"=",
"None",
",",
"crawler",
"=",
"'urllib'",
")",
":",
"if",
"cache_key",
"is",
"None",
":",
"cache_key",
"=",
"url",
"cache_path",
"=",
"cache_path_... | Retrieves the HTML code for a given URL.
If a cached version is not available, uses phantom_retrieve to fetch the page.
data - Additional data that gets passed onto the crawler.
cached - If True, retrieves the URL from the cache if it is available. If False, will still store the page in cache.
cache_k... | [
"Retrieves",
"the",
"HTML",
"code",
"for",
"a",
"given",
"URL",
".",
"If",
"a",
"cached",
"version",
"is",
"not",
"available",
"uses",
"phantom_retrieve",
"to",
"fetch",
"the",
"page",
"."
] | train | https://github.com/fdb/aufmachen/blob/f2986a0cf087ac53969f82b84d872e3f1c6986f4/aufmachen/crawler.py#L89-L117 |
ArabellaTech/aa-intercom | aa_intercom/models.py | IntercomEvent.get_intercom_data | def get_intercom_data(self):
"""Specify the data sent to Intercom API according to event type"""
data = {
"event_name": self.get_type_display(), # event type
"created_at": calendar.timegm(self.created.utctimetuple()), # date
"metadata": self.metadata
}
... | python | def get_intercom_data(self):
"""Specify the data sent to Intercom API according to event type"""
data = {
"event_name": self.get_type_display(), # event type
"created_at": calendar.timegm(self.created.utctimetuple()), # date
"metadata": self.metadata
}
... | [
"def",
"get_intercom_data",
"(",
"self",
")",
":",
"data",
"=",
"{",
"\"event_name\"",
":",
"self",
".",
"get_type_display",
"(",
")",
",",
"# event type",
"\"created_at\"",
":",
"calendar",
".",
"timegm",
"(",
"self",
".",
"created",
".",
"utctimetuple",
"(... | Specify the data sent to Intercom API according to event type | [
"Specify",
"the",
"data",
"sent",
"to",
"Intercom",
"API",
"according",
"to",
"event",
"type"
] | train | https://github.com/ArabellaTech/aa-intercom/blob/f7e2ab63967529660f9c2fe4f1d0bf3cec1502c2/aa_intercom/models.py#L33-L42 |
openp2pdesign/makerlabs | makerlabs/makeinitaly_foundation.py | get_lab_text | def get_lab_text(lab_slug, language):
"""Gets text description in English or Italian from a single lab from makeinitaly.foundation."""
if language == "English" or language == "english" or language == "EN" or language == "En":
language = "en"
elif language == "Italian" or language == "italian" or lan... | python | def get_lab_text(lab_slug, language):
"""Gets text description in English or Italian from a single lab from makeinitaly.foundation."""
if language == "English" or language == "english" or language == "EN" or language == "En":
language = "en"
elif language == "Italian" or language == "italian" or lan... | [
"def",
"get_lab_text",
"(",
"lab_slug",
",",
"language",
")",
":",
"if",
"language",
"==",
"\"English\"",
"or",
"language",
"==",
"\"english\"",
"or",
"language",
"==",
"\"EN\"",
"or",
"language",
"==",
"\"En\"",
":",
"language",
"=",
"\"en\"",
"elif",
"lang... | Gets text description in English or Italian from a single lab from makeinitaly.foundation. | [
"Gets",
"text",
"description",
"in",
"English",
"or",
"Italian",
"from",
"a",
"single",
"lab",
"from",
"makeinitaly",
".",
"foundation",
"."
] | train | https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/makeinitaly_foundation.py#L34-L61 |
openp2pdesign/makerlabs | makerlabs/makeinitaly_foundation.py | get_single_lab | def get_single_lab(lab_slug):
"""Gets data from a single lab from makeinitaly.foundation."""
wiki = MediaWiki(makeinitaly__foundation_api_url)
wiki_response = wiki.call(
{'action': 'query',
'titles': lab_slug,
'prop': 'revisions',
'rvprop': 'content'})
# If we don't k... | python | def get_single_lab(lab_slug):
"""Gets data from a single lab from makeinitaly.foundation."""
wiki = MediaWiki(makeinitaly__foundation_api_url)
wiki_response = wiki.call(
{'action': 'query',
'titles': lab_slug,
'prop': 'revisions',
'rvprop': 'content'})
# If we don't k... | [
"def",
"get_single_lab",
"(",
"lab_slug",
")",
":",
"wiki",
"=",
"MediaWiki",
"(",
"makeinitaly__foundation_api_url",
")",
"wiki_response",
"=",
"wiki",
".",
"call",
"(",
"{",
"'action'",
":",
"'query'",
",",
"'titles'",
":",
"lab_slug",
",",
"'prop'",
":",
... | Gets data from a single lab from makeinitaly.foundation. | [
"Gets",
"data",
"from",
"a",
"single",
"lab",
"from",
"makeinitaly",
".",
"foundation",
"."
] | train | https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/makeinitaly_foundation.py#L64-L137 |
openp2pdesign/makerlabs | makerlabs/makeinitaly_foundation.py | get_labs | def get_labs(format):
"""Gets data from all labs from makeinitaly.foundation."""
labs = []
# Get the first page of data
wiki = MediaWiki(makeinitaly__foundation_api_url)
wiki_response = wiki.call(
{'action': 'query',
'list': 'categorymembers',
'cmtitle': 'Category:Italian... | python | def get_labs(format):
"""Gets data from all labs from makeinitaly.foundation."""
labs = []
# Get the first page of data
wiki = MediaWiki(makeinitaly__foundation_api_url)
wiki_response = wiki.call(
{'action': 'query',
'list': 'categorymembers',
'cmtitle': 'Category:Italian... | [
"def",
"get_labs",
"(",
"format",
")",
":",
"labs",
"=",
"[",
"]",
"# Get the first page of data",
"wiki",
"=",
"MediaWiki",
"(",
"makeinitaly__foundation_api_url",
")",
"wiki_response",
"=",
"wiki",
".",
"call",
"(",
"{",
"'action'",
":",
"'query'",
",",
"'li... | Gets data from all labs from makeinitaly.foundation. | [
"Gets",
"data",
"from",
"all",
"labs",
"from",
"makeinitaly",
".",
"foundation",
"."
] | train | https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/makeinitaly_foundation.py#L140-L225 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.