id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
43,200 | bastikr/boolean.py | boolean/boolean.py | NOT.demorgan | def demorgan(self):
"""
Return a expr where the NOT function is moved inward.
This is achieved by canceling double NOTs and using De Morgan laws.
"""
expr = self.cancel()
if expr.isliteral or not isinstance(expr, self.NOT):
return expr
op = expr.args[0... | python | def demorgan(self):
"""
Return a expr where the NOT function is moved inward.
This is achieved by canceling double NOTs and using De Morgan laws.
"""
expr = self.cancel()
if expr.isliteral or not isinstance(expr, self.NOT):
return expr
op = expr.args[0... | [
"def",
"demorgan",
"(",
"self",
")",
":",
"expr",
"=",
"self",
".",
"cancel",
"(",
")",
"if",
"expr",
".",
"isliteral",
"or",
"not",
"isinstance",
"(",
"expr",
",",
"self",
".",
"NOT",
")",
":",
"return",
"expr",
"op",
"=",
"expr",
".",
"args",
"... | Return a expr where the NOT function is moved inward.
This is achieved by canceling double NOTs and using De Morgan laws. | [
"Return",
"a",
"expr",
"where",
"the",
"NOT",
"function",
"is",
"moved",
"inward",
".",
"This",
"is",
"achieved",
"by",
"canceling",
"double",
"NOTs",
"and",
"using",
"De",
"Morgan",
"laws",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1075-L1084 |
43,201 | bastikr/boolean.py | boolean/boolean.py | NOT.pretty | def pretty(self, indent=1, debug=False):
"""
Return a pretty formatted representation of self.
Include additional debug details if `debug` is True.
"""
debug_details = ''
if debug:
debug_details += '<isliteral=%r, iscanonical=%r>' % (self.isliteral, self.iscan... | python | def pretty(self, indent=1, debug=False):
"""
Return a pretty formatted representation of self.
Include additional debug details if `debug` is True.
"""
debug_details = ''
if debug:
debug_details += '<isliteral=%r, iscanonical=%r>' % (self.isliteral, self.iscan... | [
"def",
"pretty",
"(",
"self",
",",
"indent",
"=",
"1",
",",
"debug",
"=",
"False",
")",
":",
"debug_details",
"=",
"''",
"if",
"debug",
":",
"debug_details",
"+=",
"'<isliteral=%r, iscanonical=%r>'",
"%",
"(",
"self",
".",
"isliteral",
",",
"self",
".",
... | Return a pretty formatted representation of self.
Include additional debug details if `debug` is True. | [
"Return",
"a",
"pretty",
"formatted",
"representation",
"of",
"self",
".",
"Include",
"additional",
"debug",
"details",
"if",
"debug",
"is",
"True",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1089-L1101 |
43,202 | bastikr/boolean.py | boolean/boolean.py | DualBase.simplify | def simplify(self):
"""
Return a new simplified expression in canonical form from this
expression.
For simplification of AND and OR fthe ollowing rules are used
recursively bottom up:
- Associativity (output does not contain same operations nested)
- Annihilati... | python | def simplify(self):
"""
Return a new simplified expression in canonical form from this
expression.
For simplification of AND and OR fthe ollowing rules are used
recursively bottom up:
- Associativity (output does not contain same operations nested)
- Annihilati... | [
"def",
"simplify",
"(",
"self",
")",
":",
"# TODO: Refactor DualBase.simplify into different \"sub-evals\".",
"# If self is already canonical do nothing.",
"if",
"self",
".",
"iscanonical",
":",
"return",
"self",
"# Otherwise bring arguments into canonical form.",
"args",
"=",
"[... | Return a new simplified expression in canonical form from this
expression.
For simplification of AND and OR fthe ollowing rules are used
recursively bottom up:
- Associativity (output does not contain same operations nested)
- Annihilation
- Idempotence
- Ide... | [
"Return",
"a",
"new",
"simplified",
"expression",
"in",
"canonical",
"form",
"from",
"this",
"expression",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1138-L1262 |
43,203 | bastikr/boolean.py | boolean/boolean.py | DualBase.flatten | def flatten(self):
"""
Return a new expression where nested terms of this expression are
flattened as far as possible.
E.g. A & (B & C) becomes A & B & C.
"""
args = list(self.args)
i = 0
for arg in self.args:
if isinstance(arg, self.__class__... | python | def flatten(self):
"""
Return a new expression where nested terms of this expression are
flattened as far as possible.
E.g. A & (B & C) becomes A & B & C.
"""
args = list(self.args)
i = 0
for arg in self.args:
if isinstance(arg, self.__class__... | [
"def",
"flatten",
"(",
"self",
")",
":",
"args",
"=",
"list",
"(",
"self",
".",
"args",
")",
"i",
"=",
"0",
"for",
"arg",
"in",
"self",
".",
"args",
":",
"if",
"isinstance",
"(",
"arg",
",",
"self",
".",
"__class__",
")",
":",
"args",
"[",
"i",... | Return a new expression where nested terms of this expression are
flattened as far as possible.
E.g. A & (B & C) becomes A & B & C. | [
"Return",
"a",
"new",
"expression",
"where",
"nested",
"terms",
"of",
"this",
"expression",
"are",
"flattened",
"as",
"far",
"as",
"possible",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1264-L1280 |
43,204 | bastikr/boolean.py | boolean/boolean.py | DualBase.absorb | def absorb(self, args):
"""
Given an `args` sequence of expressions, return a new list of expression
applying absorption and negative absorption.
See https://en.wikipedia.org/wiki/Absorption_law
Absorption: A & (A | B) = A, A | (A & B) = A
Negative absorption: A & (~A |... | python | def absorb(self, args):
"""
Given an `args` sequence of expressions, return a new list of expression
applying absorption and negative absorption.
See https://en.wikipedia.org/wiki/Absorption_law
Absorption: A & (A | B) = A, A | (A & B) = A
Negative absorption: A & (~A |... | [
"def",
"absorb",
"(",
"self",
",",
"args",
")",
":",
"args",
"=",
"list",
"(",
"args",
")",
"if",
"not",
"args",
":",
"args",
"=",
"list",
"(",
"self",
".",
"args",
")",
"i",
"=",
"0",
"while",
"i",
"<",
"len",
"(",
"args",
")",
":",
"absorbe... | Given an `args` sequence of expressions, return a new list of expression
applying absorption and negative absorption.
See https://en.wikipedia.org/wiki/Absorption_law
Absorption: A & (A | B) = A, A | (A & B) = A
Negative absorption: A & (~A | B) = A & B, A | (~A & B) = A | B | [
"Given",
"an",
"args",
"sequence",
"of",
"expressions",
"return",
"a",
"new",
"list",
"of",
"expression",
"applying",
"absorption",
"and",
"negative",
"absorption",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1282-L1349 |
43,205 | bastikr/boolean.py | boolean/boolean.py | DualBase.subtract | def subtract(self, expr, simplify):
"""
Return a new expression where the `expr` expression has been removed
from this expression if it exists.
"""
args = self.args
if expr in self.args:
args = list(self.args)
args.remove(expr)
elif isinsta... | python | def subtract(self, expr, simplify):
"""
Return a new expression where the `expr` expression has been removed
from this expression if it exists.
"""
args = self.args
if expr in self.args:
args = list(self.args)
args.remove(expr)
elif isinsta... | [
"def",
"subtract",
"(",
"self",
",",
"expr",
",",
"simplify",
")",
":",
"args",
"=",
"self",
".",
"args",
"if",
"expr",
"in",
"self",
".",
"args",
":",
"args",
"=",
"list",
"(",
"self",
".",
"args",
")",
"args",
".",
"remove",
"(",
"expr",
")",
... | Return a new expression where the `expr` expression has been removed
from this expression if it exists. | [
"Return",
"a",
"new",
"expression",
"where",
"the",
"expr",
"expression",
"has",
"been",
"removed",
"from",
"this",
"expression",
"if",
"it",
"exists",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1351-L1371 |
43,206 | bastikr/boolean.py | boolean/boolean.py | DualBase.distributive | def distributive(self):
"""
Return a term where the leading AND or OR terms are switched.
This is done by applying the distributive laws:
A & (B|C) = (A&B) | (A&C)
A | (B&C) = (A|B) & (A|C)
"""
dual = self.dual
args = list(self.args)
for i... | python | def distributive(self):
"""
Return a term where the leading AND or OR terms are switched.
This is done by applying the distributive laws:
A & (B|C) = (A&B) | (A&C)
A | (B&C) = (A|B) & (A|C)
"""
dual = self.dual
args = list(self.args)
for i... | [
"def",
"distributive",
"(",
"self",
")",
":",
"dual",
"=",
"self",
".",
"dual",
"args",
"=",
"list",
"(",
"self",
".",
"args",
")",
"for",
"i",
",",
"arg",
"in",
"enumerate",
"(",
"args",
")",
":",
"if",
"isinstance",
"(",
"arg",
",",
"dual",
")"... | Return a term where the leading AND or OR terms are switched.
This is done by applying the distributive laws:
A & (B|C) = (A&B) | (A&C)
A | (B&C) = (A|B) & (A|C) | [
"Return",
"a",
"term",
"where",
"the",
"leading",
"AND",
"or",
"OR",
"terms",
"are",
"switched",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1373-L1395 |
43,207 | IvanMalison/okcupyd | okcupyd/looking_for.py | LookingFor.ages | def ages(self):
"""The age range that the user is interested in."""
match = self._ages_re.match(self.raw_fields.get('ages'))
if not match:
match = self._ages_re2.match(self.raw_fields.get('ages'))
return self.Ages(int(match.group(1)),int(match.group(1)))
return se... | python | def ages(self):
"""The age range that the user is interested in."""
match = self._ages_re.match(self.raw_fields.get('ages'))
if not match:
match = self._ages_re2.match(self.raw_fields.get('ages'))
return self.Ages(int(match.group(1)),int(match.group(1)))
return se... | [
"def",
"ages",
"(",
"self",
")",
":",
"match",
"=",
"self",
".",
"_ages_re",
".",
"match",
"(",
"self",
".",
"raw_fields",
".",
"get",
"(",
"'ages'",
")",
")",
"if",
"not",
"match",
":",
"match",
"=",
"self",
".",
"_ages_re2",
".",
"match",
"(",
... | The age range that the user is interested in. | [
"The",
"age",
"range",
"that",
"the",
"user",
"is",
"interested",
"in",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/looking_for.py#L68-L74 |
43,208 | IvanMalison/okcupyd | okcupyd/looking_for.py | LookingFor.single | def single(self):
"""Whether or not the user is only interested in people that are single.
"""
return 'display: none;' not in self._looking_for_xpb.li(id='ajax_single').\
one_(self._profile.profile_tree).attrib['style'] | python | def single(self):
"""Whether or not the user is only interested in people that are single.
"""
return 'display: none;' not in self._looking_for_xpb.li(id='ajax_single').\
one_(self._profile.profile_tree).attrib['style'] | [
"def",
"single",
"(",
"self",
")",
":",
"return",
"'display: none;'",
"not",
"in",
"self",
".",
"_looking_for_xpb",
".",
"li",
"(",
"id",
"=",
"'ajax_single'",
")",
".",
"one_",
"(",
"self",
".",
"_profile",
".",
"profile_tree",
")",
".",
"attrib",
"[",
... | Whether or not the user is only interested in people that are single. | [
"Whether",
"or",
"not",
"the",
"user",
"is",
"only",
"interested",
"in",
"people",
"that",
"are",
"single",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/looking_for.py#L77-L81 |
43,209 | IvanMalison/okcupyd | okcupyd/looking_for.py | LookingFor.update | def update(self, ages=None, single=None, near_me=None, kinds=None,
gentation=None):
"""Update the looking for attributes of the logged in user.
:param ages: The ages that the logged in user is interested in.
:type ages: tuple
:param single: Whether or not the user is only... | python | def update(self, ages=None, single=None, near_me=None, kinds=None,
gentation=None):
"""Update the looking for attributes of the logged in user.
:param ages: The ages that the logged in user is interested in.
:type ages: tuple
:param single: Whether or not the user is only... | [
"def",
"update",
"(",
"self",
",",
"ages",
"=",
"None",
",",
"single",
"=",
"None",
",",
"near_me",
"=",
"None",
",",
"kinds",
"=",
"None",
",",
"gentation",
"=",
"None",
")",
":",
"ages",
"=",
"ages",
"or",
"self",
".",
"ages",
"single",
"=",
"s... | Update the looking for attributes of the logged in user.
:param ages: The ages that the logged in user is interested in.
:type ages: tuple
:param single: Whether or not the user is only interested in people that
are single.
:type single: bool
:param near_m... | [
"Update",
"the",
"looking",
"for",
"attributes",
"of",
"the",
"logged",
"in",
"user",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/looking_for.py#L95-L140 |
43,210 | IvanMalison/okcupyd | okcupyd/photo.py | PhotoUploader.upload_and_confirm | def upload_and_confirm(self, incoming, **kwargs):
"""Upload the file to okcupid and confirm, among other things, its
thumbnail position.
:param incoming: A filepath string, :class:`.Info` object or
a file like object to upload to okcupid.com.
If... | python | def upload_and_confirm(self, incoming, **kwargs):
"""Upload the file to okcupid and confirm, among other things, its
thumbnail position.
:param incoming: A filepath string, :class:`.Info` object or
a file like object to upload to okcupid.com.
If... | [
"def",
"upload_and_confirm",
"(",
"self",
",",
"incoming",
",",
"*",
"*",
"kwargs",
")",
":",
"response_dict",
"=",
"self",
".",
"upload",
"(",
"incoming",
")",
"if",
"'error'",
"in",
"response_dict",
":",
"log",
".",
"warning",
"(",
"'Failed to upload photo... | Upload the file to okcupid and confirm, among other things, its
thumbnail position.
:param incoming: A filepath string, :class:`.Info` object or
a file like object to upload to okcupid.com.
If an info object is provided, its thumbnail
... | [
"Upload",
"the",
"file",
"to",
"okcupid",
"and",
"confirm",
"among",
"other",
"things",
"its",
"thumbnail",
"position",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/photo.py#L99-L125 |
43,211 | IvanMalison/okcupyd | okcupyd/photo.py | PhotoUploader.delete | def delete(self, photo_id, album_id=0):
"""Delete a photo from the logged in users account.
:param photo_id: The okcupid id of the photo to delete.
:param album_id: The album from which to delete the photo.
"""
if isinstance(photo_id, Info):
photo_id = photo_id.id
... | python | def delete(self, photo_id, album_id=0):
"""Delete a photo from the logged in users account.
:param photo_id: The okcupid id of the photo to delete.
:param album_id: The album from which to delete the photo.
"""
if isinstance(photo_id, Info):
photo_id = photo_id.id
... | [
"def",
"delete",
"(",
"self",
",",
"photo_id",
",",
"album_id",
"=",
"0",
")",
":",
"if",
"isinstance",
"(",
"photo_id",
",",
"Info",
")",
":",
"photo_id",
"=",
"photo_id",
".",
"id",
"return",
"self",
".",
"_session",
".",
"okc_post",
"(",
"'photouplo... | Delete a photo from the logged in users account.
:param photo_id: The okcupid id of the photo to delete.
:param album_id: The album from which to delete the photo. | [
"Delete",
"a",
"photo",
"from",
"the",
"logged",
"in",
"users",
"account",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/photo.py#L127-L140 |
43,212 | aaugustin/django-pymssql | sqlserver_pymssql/base.py | DatabaseWrapper.__get_dbms_version | def __get_dbms_version(self, make_connection=True):
"""
Returns the 'DBMS Version' string, or ''. If a connection to the
database has not already been established, a connection will be made
when `make_connection` is True.
"""
if not self.connection and make_connection:
... | python | def __get_dbms_version(self, make_connection=True):
"""
Returns the 'DBMS Version' string, or ''. If a connection to the
database has not already been established, a connection will be made
when `make_connection` is True.
"""
if not self.connection and make_connection:
... | [
"def",
"__get_dbms_version",
"(",
"self",
",",
"make_connection",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"connection",
"and",
"make_connection",
":",
"self",
".",
"connect",
"(",
")",
"with",
"self",
".",
"connection",
".",
"cursor",
"(",
")",
... | Returns the 'DBMS Version' string, or ''. If a connection to the
database has not already been established, a connection will be made
when `make_connection` is True. | [
"Returns",
"the",
"DBMS",
"Version",
"string",
"or",
".",
"If",
"a",
"connection",
"to",
"the",
"database",
"has",
"not",
"already",
"been",
"established",
"a",
"connection",
"will",
"be",
"made",
"when",
"make_connection",
"is",
"True",
"."
] | a99ca2f63fd67bc6855340ecb51dbe4f35f6bd06 | https://github.com/aaugustin/django-pymssql/blob/a99ca2f63fd67bc6855340ecb51dbe4f35f6bd06/sqlserver_pymssql/base.py#L136-L146 |
43,213 | IvanMalison/okcupyd | okcupyd/question.py | Questions.respond_from_user_question | def respond_from_user_question(self, user_question, importance):
"""Respond to a question in exactly the way that is described by
the given user_question.
:param user_question: The user question to respond with.
:type user_question: :class:`.UserQuestion`
:param importance: The ... | python | def respond_from_user_question(self, user_question, importance):
"""Respond to a question in exactly the way that is described by
the given user_question.
:param user_question: The user question to respond with.
:type user_question: :class:`.UserQuestion`
:param importance: The ... | [
"def",
"respond_from_user_question",
"(",
"self",
",",
"user_question",
",",
"importance",
")",
":",
"user_response_ids",
"=",
"[",
"option",
".",
"id",
"for",
"option",
"in",
"user_question",
".",
"answer_options",
"if",
"option",
".",
"is_users",
"]",
"match_r... | Respond to a question in exactly the way that is described by
the given user_question.
:param user_question: The user question to respond with.
:type user_question: :class:`.UserQuestion`
:param importance: The importance that should be used in responding to
t... | [
"Respond",
"to",
"a",
"question",
"in",
"exactly",
"the",
"way",
"that",
"is",
"described",
"by",
"the",
"given",
"user_question",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/question.py#L298-L318 |
43,214 | IvanMalison/okcupyd | okcupyd/question.py | Questions.respond_from_question | def respond_from_question(self, question, user_question, importance):
"""Copy the answer given in `question` to the logged in user's
profile.
:param question: A :class:`~.Question` instance to copy.
:param user_question: An instance of :class:`~.UserQuestion` that
... | python | def respond_from_question(self, question, user_question, importance):
"""Copy the answer given in `question` to the logged in user's
profile.
:param question: A :class:`~.Question` instance to copy.
:param user_question: An instance of :class:`~.UserQuestion` that
... | [
"def",
"respond_from_question",
"(",
"self",
",",
"question",
",",
"user_question",
",",
"importance",
")",
":",
"option_index",
"=",
"user_question",
".",
"answer_text_to_option",
"[",
"question",
".",
"their_answer",
"]",
".",
"id",
"self",
".",
"respond",
"("... | Copy the answer given in `question` to the logged in user's
profile.
:param question: A :class:`~.Question` instance to copy.
:param user_question: An instance of :class:`~.UserQuestion` that
corresponds to the same question as `question`.
... | [
"Copy",
"the",
"answer",
"given",
"in",
"question",
"to",
"the",
"logged",
"in",
"user",
"s",
"profile",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/question.py#L320-L335 |
43,215 | IvanMalison/okcupyd | okcupyd/user.py | User.message | def message(self, username, message_text):
"""Message an okcupid user. If an existing conversation between the
logged in user and the target user can be found, reply to that thread
instead of starting a new one.
:param username: The username of the user to which the message should
... | python | def message(self, username, message_text):
"""Message an okcupid user. If an existing conversation between the
logged in user and the target user can be found, reply to that thread
instead of starting a new one.
:param username: The username of the user to which the message should
... | [
"def",
"message",
"(",
"self",
",",
"username",
",",
"message_text",
")",
":",
"# Try to reply to an existing thread.",
"if",
"not",
"isinstance",
"(",
"username",
",",
"six",
".",
"string_types",
")",
":",
"username",
"=",
"username",
".",
"username",
"for",
... | Message an okcupid user. If an existing conversation between the
logged in user and the target user can be found, reply to that thread
instead of starting a new one.
:param username: The username of the user to which the message should
be sent.
:type username: s... | [
"Message",
"an",
"okcupid",
"user",
".",
"If",
"an",
"existing",
"conversation",
"between",
"the",
"logged",
"in",
"user",
"and",
"the",
"target",
"user",
"can",
"be",
"found",
"reply",
"to",
"that",
"thread",
"instead",
"of",
"starting",
"a",
"new",
"one"... | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/user.py#L117-L137 |
43,216 | IvanMalison/okcupyd | okcupyd/user.py | User.get_question_answer_id | def get_question_answer_id(self, question, fast=False,
bust_questions_cache=False):
"""Get the index of the answer that was given to `question`
See the documentation for :meth:`~.get_user_question` for important
caveats about the use of this function.
:pa... | python | def get_question_answer_id(self, question, fast=False,
bust_questions_cache=False):
"""Get the index of the answer that was given to `question`
See the documentation for :meth:`~.get_user_question` for important
caveats about the use of this function.
:pa... | [
"def",
"get_question_answer_id",
"(",
"self",
",",
"question",
",",
"fast",
"=",
"False",
",",
"bust_questions_cache",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"question",
",",
"'answer_id'",
")",
":",
"# Guard to handle incoming user_question.",
"return",
"q... | Get the index of the answer that was given to `question`
See the documentation for :meth:`~.get_user_question` for important
caveats about the use of this function.
:param question: The question whose `answer_id` should be retrieved.
:type question: :class:`~okcupyd.question.BaseQuesti... | [
"Get",
"the",
"index",
"of",
"the",
"answer",
"that",
"was",
"given",
"to",
"question"
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/user.py#L243-L272 |
43,217 | IvanMalison/okcupyd | okcupyd/helpers.py | update_looking_for | def update_looking_for(profile_tree, looking_for):
"""
Update looking_for attribute of a Profile.
"""
div = profile_tree.xpath("//div[@id = 'what_i_want']")[0]
looking_for['gentation'] = div.xpath(".//li[@id = 'ajax_gentation']/text()")[0].strip()
looking_for['ages'] = replace_chars(div.xpath(".... | python | def update_looking_for(profile_tree, looking_for):
"""
Update looking_for attribute of a Profile.
"""
div = profile_tree.xpath("//div[@id = 'what_i_want']")[0]
looking_for['gentation'] = div.xpath(".//li[@id = 'ajax_gentation']/text()")[0].strip()
looking_for['ages'] = replace_chars(div.xpath(".... | [
"def",
"update_looking_for",
"(",
"profile_tree",
",",
"looking_for",
")",
":",
"div",
"=",
"profile_tree",
".",
"xpath",
"(",
"\"//div[@id = 'what_i_want']\"",
")",
"[",
"0",
"]",
"looking_for",
"[",
"'gentation'",
"]",
"=",
"div",
".",
"xpath",
"(",
"\".//li... | Update looking_for attribute of a Profile. | [
"Update",
"looking_for",
"attribute",
"of",
"a",
"Profile",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/helpers.py#L237-L249 |
43,218 | IvanMalison/okcupyd | okcupyd/helpers.py | update_details | def update_details(profile_tree, details):
"""
Update details attribute of a Profile.
"""
div = profile_tree.xpath("//div[@id = 'profile_details']")[0]
for dl in div.iter('dl'):
title = dl.find('dt').text
item = dl.find('dd')
if title == 'Last Online' and item.find('span') is... | python | def update_details(profile_tree, details):
"""
Update details attribute of a Profile.
"""
div = profile_tree.xpath("//div[@id = 'profile_details']")[0]
for dl in div.iter('dl'):
title = dl.find('dt').text
item = dl.find('dd')
if title == 'Last Online' and item.find('span') is... | [
"def",
"update_details",
"(",
"profile_tree",
",",
"details",
")",
":",
"div",
"=",
"profile_tree",
".",
"xpath",
"(",
"\"//div[@id = 'profile_details']\"",
")",
"[",
"0",
"]",
"for",
"dl",
"in",
"div",
".",
"iter",
"(",
"'dl'",
")",
":",
"title",
"=",
"... | Update details attribute of a Profile. | [
"Update",
"details",
"attribute",
"of",
"a",
"Profile",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/helpers.py#L252-L266 |
43,219 | IvanMalison/okcupyd | okcupyd/helpers.py | get_default_gentation | def get_default_gentation(gender, orientation):
"""Return the default gentation for the given gender and orientation."""
gender = gender.lower()[0]
orientation = orientation.lower()
return gender_to_orientation_to_gentation[gender][orientation] | python | def get_default_gentation(gender, orientation):
"""Return the default gentation for the given gender and orientation."""
gender = gender.lower()[0]
orientation = orientation.lower()
return gender_to_orientation_to_gentation[gender][orientation] | [
"def",
"get_default_gentation",
"(",
"gender",
",",
"orientation",
")",
":",
"gender",
"=",
"gender",
".",
"lower",
"(",
")",
"[",
"0",
"]",
"orientation",
"=",
"orientation",
".",
"lower",
"(",
")",
"return",
"gender_to_orientation_to_gentation",
"[",
"gender... | Return the default gentation for the given gender and orientation. | [
"Return",
"the",
"default",
"gentation",
"for",
"the",
"given",
"gender",
"and",
"orientation",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/helpers.py#L288-L292 |
43,220 | IvanMalison/okcupyd | okcupyd/db/mailbox.py | Sync.update_mailbox | def update_mailbox(self, mailbox_name='inbox'):
"""Update the mailbox associated with the given mailbox name.
"""
with txn() as session:
last_updated_name = '{0}_last_updated'.format(mailbox_name)
okcupyd_user = session.query(model.OKCupydUser).join(model.User).filter(
... | python | def update_mailbox(self, mailbox_name='inbox'):
"""Update the mailbox associated with the given mailbox name.
"""
with txn() as session:
last_updated_name = '{0}_last_updated'.format(mailbox_name)
okcupyd_user = session.query(model.OKCupydUser).join(model.User).filter(
... | [
"def",
"update_mailbox",
"(",
"self",
",",
"mailbox_name",
"=",
"'inbox'",
")",
":",
"with",
"txn",
"(",
")",
"as",
"session",
":",
"last_updated_name",
"=",
"'{0}_last_updated'",
".",
"format",
"(",
"mailbox_name",
")",
"okcupyd_user",
"=",
"session",
".",
... | Update the mailbox associated with the given mailbox name. | [
"Update",
"the",
"mailbox",
"associated",
"with",
"the",
"given",
"mailbox",
"name",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/db/mailbox.py#L25-L49 |
43,221 | IvanMalison/okcupyd | okcupyd/profile_copy.py | Copy.photos | def photos(self):
"""Copy photos to the destination user."""
# Reverse because pictures appear in inverse chronological order.
for photo_info in self.dest_user.profile.photo_infos:
self.dest_user.photo.delete(photo_info)
return [self.dest_user.photo.upload_and_confirm(info)
... | python | def photos(self):
"""Copy photos to the destination user."""
# Reverse because pictures appear in inverse chronological order.
for photo_info in self.dest_user.profile.photo_infos:
self.dest_user.photo.delete(photo_info)
return [self.dest_user.photo.upload_and_confirm(info)
... | [
"def",
"photos",
"(",
"self",
")",
":",
"# Reverse because pictures appear in inverse chronological order.",
"for",
"photo_info",
"in",
"self",
".",
"dest_user",
".",
"profile",
".",
"photo_infos",
":",
"self",
".",
"dest_user",
".",
"photo",
".",
"delete",
"(",
"... | Copy photos to the destination user. | [
"Copy",
"photos",
"to",
"the",
"destination",
"user",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/profile_copy.py#L107-L113 |
43,222 | IvanMalison/okcupyd | okcupyd/profile_copy.py | Copy.essays | def essays(self):
"""Copy essays from the source profile to the destination profile."""
for essay_name in self.dest_user.profile.essays.essay_names:
setattr(self.dest_user.profile.essays, essay_name,
getattr(self.source_profile.essays, essay_name)) | python | def essays(self):
"""Copy essays from the source profile to the destination profile."""
for essay_name in self.dest_user.profile.essays.essay_names:
setattr(self.dest_user.profile.essays, essay_name,
getattr(self.source_profile.essays, essay_name)) | [
"def",
"essays",
"(",
"self",
")",
":",
"for",
"essay_name",
"in",
"self",
".",
"dest_user",
".",
"profile",
".",
"essays",
".",
"essay_names",
":",
"setattr",
"(",
"self",
".",
"dest_user",
".",
"profile",
".",
"essays",
",",
"essay_name",
",",
"getattr... | Copy essays from the source profile to the destination profile. | [
"Copy",
"essays",
"from",
"the",
"source",
"profile",
"to",
"the",
"destination",
"profile",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/profile_copy.py#L115-L119 |
43,223 | IvanMalison/okcupyd | okcupyd/profile_copy.py | Copy.looking_for | def looking_for(self):
"""Copy looking for attributes from the source profile to the
destination profile.
"""
looking_for = self.source_profile.looking_for
return self.dest_user.profile.looking_for.update(
gentation=looking_for.gentation,
single=looking_fo... | python | def looking_for(self):
"""Copy looking for attributes from the source profile to the
destination profile.
"""
looking_for = self.source_profile.looking_for
return self.dest_user.profile.looking_for.update(
gentation=looking_for.gentation,
single=looking_fo... | [
"def",
"looking_for",
"(",
"self",
")",
":",
"looking_for",
"=",
"self",
".",
"source_profile",
".",
"looking_for",
"return",
"self",
".",
"dest_user",
".",
"profile",
".",
"looking_for",
".",
"update",
"(",
"gentation",
"=",
"looking_for",
".",
"gentation",
... | Copy looking for attributes from the source profile to the
destination profile. | [
"Copy",
"looking",
"for",
"attributes",
"from",
"the",
"source",
"profile",
"to",
"the",
"destination",
"profile",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/profile_copy.py#L121-L132 |
43,224 | IvanMalison/okcupyd | okcupyd/profile_copy.py | Copy.details | def details(self):
"""Copy details from the source profile to the destination profile."""
return self.dest_user.profile.details.convert_and_update(
self.source_profile.details.as_dict
) | python | def details(self):
"""Copy details from the source profile to the destination profile."""
return self.dest_user.profile.details.convert_and_update(
self.source_profile.details.as_dict
) | [
"def",
"details",
"(",
"self",
")",
":",
"return",
"self",
".",
"dest_user",
".",
"profile",
".",
"details",
".",
"convert_and_update",
"(",
"self",
".",
"source_profile",
".",
"details",
".",
"as_dict",
")"
] | Copy details from the source profile to the destination profile. | [
"Copy",
"details",
"from",
"the",
"source",
"profile",
"to",
"the",
"destination",
"profile",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/profile_copy.py#L134-L138 |
43,225 | IvanMalison/okcupyd | okcupyd/profile.py | Profile.message | def message(self, message, thread_id=None):
"""Message the user associated with this profile.
:param message: The message to send to this user.
:param thread_id: The id of the thread to respond to, if any.
"""
return_value = helpers.Messager(self._session).send(
self... | python | def message(self, message, thread_id=None):
"""Message the user associated with this profile.
:param message: The message to send to this user.
:param thread_id: The id of the thread to respond to, if any.
"""
return_value = helpers.Messager(self._session).send(
self... | [
"def",
"message",
"(",
"self",
",",
"message",
",",
"thread_id",
"=",
"None",
")",
":",
"return_value",
"=",
"helpers",
".",
"Messager",
"(",
"self",
".",
"_session",
")",
".",
"send",
"(",
"self",
".",
"username",
",",
"message",
",",
"self",
".",
"... | Message the user associated with this profile.
:param message: The message to send to this user.
:param thread_id: The id of the thread to respond to, if any. | [
"Message",
"the",
"user",
"associated",
"with",
"this",
"profile",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/profile.py#L284-L294 |
43,226 | IvanMalison/okcupyd | okcupyd/profile.py | Profile.rate | def rate(self, rating):
"""Rate this profile as the user that was logged in with the session
that this object was instantiated with.
:param rating: The rating to give this user.
"""
parameters = {
'voterid': self._current_user_id,
'target_userid': self.id... | python | def rate(self, rating):
"""Rate this profile as the user that was logged in with the session
that this object was instantiated with.
:param rating: The rating to give this user.
"""
parameters = {
'voterid': self._current_user_id,
'target_userid': self.id... | [
"def",
"rate",
"(",
"self",
",",
"rating",
")",
":",
"parameters",
"=",
"{",
"'voterid'",
":",
"self",
".",
"_current_user_id",
",",
"'target_userid'",
":",
"self",
".",
"id",
",",
"'type'",
":",
"'vote'",
",",
"'cf'",
":",
"'profile2'",
",",
"'target_ob... | Rate this profile as the user that was logged in with the session
that this object was instantiated with.
:param rating: The rating to give this user. | [
"Rate",
"this",
"profile",
"as",
"the",
"user",
"that",
"was",
"logged",
"in",
"with",
"the",
"session",
"that",
"this",
"object",
"was",
"instantiated",
"with",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/profile.py#L318-L341 |
43,227 | IvanMalison/okcupyd | okcupyd/util/currying.py | curry.arity_evaluation_checker | def arity_evaluation_checker(function):
"""Build an evaluation checker that will return True when it is
guaranteed that all positional arguments have been accounted for.
"""
is_class = inspect.isclass(function)
if is_class:
function = function.__init__
functio... | python | def arity_evaluation_checker(function):
"""Build an evaluation checker that will return True when it is
guaranteed that all positional arguments have been accounted for.
"""
is_class = inspect.isclass(function)
if is_class:
function = function.__init__
functio... | [
"def",
"arity_evaluation_checker",
"(",
"function",
")",
":",
"is_class",
"=",
"inspect",
".",
"isclass",
"(",
"function",
")",
"if",
"is_class",
":",
"function",
"=",
"function",
".",
"__init__",
"function_info",
"=",
"inspect",
".",
"getargspec",
"(",
"funct... | Build an evaluation checker that will return True when it is
guaranteed that all positional arguments have been accounted for. | [
"Build",
"an",
"evaluation",
"checker",
"that",
"will",
"return",
"True",
"when",
"it",
"is",
"guaranteed",
"that",
"all",
"positional",
"arguments",
"have",
"been",
"accounted",
"for",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/util/currying.py#L90-L119 |
43,228 | IvanMalison/okcupyd | tasks.py | rerecord | def rerecord(ctx, rest):
"""Rerecord tests."""
run('tox -e py27 -- --cassette-mode all --record --credentials {0} -s'
.format(rest), pty=True)
run('tox -e py27 -- --resave --scrub --credentials test_credentials {0} -s'
.format(rest), pty=True) | python | def rerecord(ctx, rest):
"""Rerecord tests."""
run('tox -e py27 -- --cassette-mode all --record --credentials {0} -s'
.format(rest), pty=True)
run('tox -e py27 -- --resave --scrub --credentials test_credentials {0} -s'
.format(rest), pty=True) | [
"def",
"rerecord",
"(",
"ctx",
",",
"rest",
")",
":",
"run",
"(",
"'tox -e py27 -- --cassette-mode all --record --credentials {0} -s'",
".",
"format",
"(",
"rest",
")",
",",
"pty",
"=",
"True",
")",
"run",
"(",
"'tox -e py27 -- --resave --scrub --credentials test_creden... | Rerecord tests. | [
"Rerecord",
"tests",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/tasks.py#L31-L36 |
43,229 | dixudx/rtcclient | rtcclient/query.py | Query.runSavedQueryByUrl | def runSavedQueryByUrl(self, saved_query_url, returned_properties=None):
"""Query workitems using the saved query url
:param saved_query_url: the saved query url
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more ... | python | def runSavedQueryByUrl(self, saved_query_url, returned_properties=None):
"""Query workitems using the saved query url
:param saved_query_url: the saved query url
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more ... | [
"def",
"runSavedQueryByUrl",
"(",
"self",
",",
"saved_query_url",
",",
"returned_properties",
"=",
"None",
")",
":",
"try",
":",
"if",
"\"=\"",
"not",
"in",
"saved_query_url",
":",
"raise",
"exception",
".",
"BadValue",
"(",
")",
"saved_query_id",
"=",
"saved_... | Query workitems using the saved query url
:param saved_query_url: the saved query url
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:return: a :class:`list` that contains the queried
... | [
"Query",
"workitems",
"using",
"the",
"saved",
"query",
"url"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/query.py#L184-L206 |
43,230 | dixudx/rtcclient | rtcclient/query.py | Query.runSavedQueryByID | def runSavedQueryByID(self, saved_query_id, returned_properties=None):
"""Query workitems using the saved query id
This saved query id can be obtained by below two methods:
1. :class:`rtcclient.models.SavedQuery` object (e.g.
mysavedquery.id)
2. your saved query url (e.g.
... | python | def runSavedQueryByID(self, saved_query_id, returned_properties=None):
"""Query workitems using the saved query id
This saved query id can be obtained by below two methods:
1. :class:`rtcclient.models.SavedQuery` object (e.g.
mysavedquery.id)
2. your saved query url (e.g.
... | [
"def",
"runSavedQueryByID",
"(",
"self",
",",
"saved_query_id",
",",
"returned_properties",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"saved_query_id",
",",
"six",
".",
"string_types",
")",
"or",
"not",
"saved_query_id",
":",
"excp_msg",
"=",
"\"P... | Query workitems using the saved query id
This saved query id can be obtained by below two methods:
1. :class:`rtcclient.models.SavedQuery` object (e.g.
mysavedquery.id)
2. your saved query url (e.g.
https://myrtc:9443/jazz/web/xxx#action=xxxx%id=_mGYe0CWgEeGofp83pg),
w... | [
"Query",
"workitems",
"using",
"the",
"saved",
"query",
"id"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/query.py#L208-L234 |
43,231 | dixudx/rtcclient | rtcclient/base.py | RTCBase.put | def put(self, url, data=None, verify=False,
headers=None, proxies=None, timeout=60, **kwargs):
"""Sends a PUT request. Refactor from requests module
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, bytes, or file-like object to
sen... | python | def put(self, url, data=None, verify=False,
headers=None, proxies=None, timeout=60, **kwargs):
"""Sends a PUT request. Refactor from requests module
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, bytes, or file-like object to
sen... | [
"def",
"put",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"verify",
"=",
"False",
",",
"headers",
"=",
"None",
",",
"proxies",
"=",
"None",
",",
"timeout",
"=",
"60",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"log",
".",
"debu... | Sends a PUT request. Refactor from requests module
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, bytes, or file-like object to
send in the body of the :class:`Request`.
:param verify: (optional) if ``True``, the SSL cert will be verified.
... | [
"Sends",
"a",
"PUT",
"request",
".",
"Refactor",
"from",
"requests",
"module"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/base.py#L127-L159 |
43,232 | dixudx/rtcclient | rtcclient/base.py | RTCBase.validate_url | def validate_url(cls, url):
"""Strip and trailing slash to validate a url
:param url: the url address
:return: the valid url address
:rtype: string
"""
if url is None:
return None
url = url.strip()
while url.endswith('/'):
url = ... | python | def validate_url(cls, url):
"""Strip and trailing slash to validate a url
:param url: the url address
:return: the valid url address
:rtype: string
"""
if url is None:
return None
url = url.strip()
while url.endswith('/'):
url = ... | [
"def",
"validate_url",
"(",
"cls",
",",
"url",
")",
":",
"if",
"url",
"is",
"None",
":",
"return",
"None",
"url",
"=",
"url",
".",
"strip",
"(",
")",
"while",
"url",
".",
"endswith",
"(",
"'/'",
")",
":",
"url",
"=",
"url",
"[",
":",
"-",
"1",
... | Strip and trailing slash to validate a url
:param url: the url address
:return: the valid url address
:rtype: string | [
"Strip",
"and",
"trailing",
"slash",
"to",
"validate",
"a",
"url"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/base.py#L198-L212 |
43,233 | dixudx/rtcclient | rtcclient/base.py | FieldBase._initialize | def _initialize(self):
"""Initialize the object from the request"""
self.log.debug("Start initializing data from %s",
self.url)
resp = self.get(self.url,
verify=False,
proxies=self.rtc_obj.proxies,
he... | python | def _initialize(self):
"""Initialize the object from the request"""
self.log.debug("Start initializing data from %s",
self.url)
resp = self.get(self.url,
verify=False,
proxies=self.rtc_obj.proxies,
he... | [
"def",
"_initialize",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Start initializing data from %s\"",
",",
"self",
".",
"url",
")",
"resp",
"=",
"self",
".",
"get",
"(",
"self",
".",
"url",
",",
"verify",
"=",
"False",
",",
"proxie... | Initialize the object from the request | [
"Initialize",
"the",
"object",
"from",
"the",
"request"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/base.py#L236-L247 |
43,234 | dixudx/rtcclient | rtcclient/base.py | FieldBase.__initialize | def __initialize(self, resp):
"""Initialize from the response"""
raw_data = xmltodict.parse(resp.content)
root_key = list(raw_data.keys())[0]
self.raw_data = raw_data.get(root_key)
self.__initializeFromRaw() | python | def __initialize(self, resp):
"""Initialize from the response"""
raw_data = xmltodict.parse(resp.content)
root_key = list(raw_data.keys())[0]
self.raw_data = raw_data.get(root_key)
self.__initializeFromRaw() | [
"def",
"__initialize",
"(",
"self",
",",
"resp",
")",
":",
"raw_data",
"=",
"xmltodict",
".",
"parse",
"(",
"resp",
".",
"content",
")",
"root_key",
"=",
"list",
"(",
"raw_data",
".",
"keys",
"(",
")",
")",
"[",
"0",
"]",
"self",
".",
"raw_data",
"... | Initialize from the response | [
"Initialize",
"from",
"the",
"response"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/base.py#L249-L255 |
43,235 | dixudx/rtcclient | rtcclient/client.py | RTCClient.getTemplate | def getTemplate(self, copied_from, template_name=None,
template_folder=None, keep=False, encoding="UTF-8"):
"""Get template from some to-be-copied workitems
More details, please refer to
:class:`rtcclient.template.Templater.getTemplate`
"""
return self.templ... | python | def getTemplate(self, copied_from, template_name=None,
template_folder=None, keep=False, encoding="UTF-8"):
"""Get template from some to-be-copied workitems
More details, please refer to
:class:`rtcclient.template.Templater.getTemplate`
"""
return self.templ... | [
"def",
"getTemplate",
"(",
"self",
",",
"copied_from",
",",
"template_name",
"=",
"None",
",",
"template_folder",
"=",
"None",
",",
"keep",
"=",
"False",
",",
"encoding",
"=",
"\"UTF-8\"",
")",
":",
"return",
"self",
".",
"templater",
".",
"getTemplate",
"... | Get template from some to-be-copied workitems
More details, please refer to
:class:`rtcclient.template.Templater.getTemplate` | [
"Get",
"template",
"from",
"some",
"to",
"-",
"be",
"-",
"copied",
"workitems"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L824-L836 |
43,236 | dixudx/rtcclient | rtcclient/client.py | RTCClient.getTemplates | def getTemplates(self, workitems, template_folder=None,
template_names=None, keep=False, encoding="UTF-8"):
"""Get templates from a group of to-be-copied workitems
and write them to files named after the names in `template_names`
respectively.
More details, please r... | python | def getTemplates(self, workitems, template_folder=None,
template_names=None, keep=False, encoding="UTF-8"):
"""Get templates from a group of to-be-copied workitems
and write them to files named after the names in `template_names`
respectively.
More details, please r... | [
"def",
"getTemplates",
"(",
"self",
",",
"workitems",
",",
"template_folder",
"=",
"None",
",",
"template_names",
"=",
"None",
",",
"keep",
"=",
"False",
",",
"encoding",
"=",
"\"UTF-8\"",
")",
":",
"self",
".",
"templater",
".",
"getTemplates",
"(",
"work... | Get templates from a group of to-be-copied workitems
and write them to files named after the names in `template_names`
respectively.
More details, please refer to
:class:`rtcclient.template.Templater.getTemplates` | [
"Get",
"templates",
"from",
"a",
"group",
"of",
"to",
"-",
"be",
"-",
"copied",
"workitems",
"and",
"write",
"them",
"to",
"files",
"named",
"after",
"the",
"names",
"in",
"template_names",
"respectively",
"."
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L838-L852 |
43,237 | dixudx/rtcclient | rtcclient/client.py | RTCClient.listFieldsFromWorkitem | def listFieldsFromWorkitem(self, copied_from, keep=False):
"""List all the attributes to be rendered directly from some
to-be-copied workitems
More details, please refer to
:class:`rtcclient.template.Templater.listFieldsFromWorkitem`
"""
return self.templater.listFields... | python | def listFieldsFromWorkitem(self, copied_from, keep=False):
"""List all the attributes to be rendered directly from some
to-be-copied workitems
More details, please refer to
:class:`rtcclient.template.Templater.listFieldsFromWorkitem`
"""
return self.templater.listFields... | [
"def",
"listFieldsFromWorkitem",
"(",
"self",
",",
"copied_from",
",",
"keep",
"=",
"False",
")",
":",
"return",
"self",
".",
"templater",
".",
"listFieldsFromWorkitem",
"(",
"copied_from",
",",
"keep",
"=",
"keep",
")"
] | List all the attributes to be rendered directly from some
to-be-copied workitems
More details, please refer to
:class:`rtcclient.template.Templater.listFieldsFromWorkitem` | [
"List",
"all",
"the",
"attributes",
"to",
"be",
"rendered",
"directly",
"from",
"some",
"to",
"-",
"be",
"-",
"copied",
"workitems"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L870-L879 |
43,238 | dixudx/rtcclient | rtcclient/client.py | RTCClient.createWorkitem | def createWorkitem(self, item_type, title, description=None,
projectarea_id=None, projectarea_name=None,
template=None, copied_from=None, keep=False,
**kwargs):
"""Create a workitem
:param item_type: the type of the workitem
... | python | def createWorkitem(self, item_type, title, description=None,
projectarea_id=None, projectarea_name=None,
template=None, copied_from=None, keep=False,
**kwargs):
"""Create a workitem
:param item_type: the type of the workitem
... | [
"def",
"createWorkitem",
"(",
"self",
",",
"item_type",
",",
"title",
",",
"description",
"=",
"None",
",",
"projectarea_id",
"=",
"None",
",",
"projectarea_name",
"=",
"None",
",",
"template",
"=",
"None",
",",
"copied_from",
"=",
"None",
",",
"keep",
"="... | Create a workitem
:param item_type: the type of the workitem
(e.g. task/defect/issue)
:param title: the title of the new created workitem
:param description: the description of the new created workitem
:param projectarea_id: the :class:`rtcclient.project_area.ProjectArea`
... | [
"Create",
"a",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L1002-L1073 |
43,239 | dixudx/rtcclient | rtcclient/client.py | RTCClient.copyWorkitem | def copyWorkitem(self, copied_from, title=None, description=None,
prefix=None):
"""Create a workitem by copying from an existing one
:param copied_from: the to-be-copied workitem id
:param title: the new workitem title/summary.
If `None`, will copy that from a t... | python | def copyWorkitem(self, copied_from, title=None, description=None,
prefix=None):
"""Create a workitem by copying from an existing one
:param copied_from: the to-be-copied workitem id
:param title: the new workitem title/summary.
If `None`, will copy that from a t... | [
"def",
"copyWorkitem",
"(",
"self",
",",
"copied_from",
",",
"title",
"=",
"None",
",",
"description",
"=",
"None",
",",
"prefix",
"=",
"None",
")",
":",
"copied_wi",
"=",
"self",
".",
"getWorkitem",
"(",
"copied_from",
")",
"if",
"title",
"is",
"None",
... | Create a workitem by copying from an existing one
:param copied_from: the to-be-copied workitem id
:param title: the new workitem title/summary.
If `None`, will copy that from a to-be-copied workitem
:param description: the new workitem description.
If `None`, will copy ... | [
"Create",
"a",
"workitem",
"by",
"copying",
"from",
"an",
"existing",
"one"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L1075-L1113 |
43,240 | dixudx/rtcclient | rtcclient/client.py | RTCClient._checkMissingParams | def _checkMissingParams(self, template, **kwargs):
"""Check the missing parameters for rendering from the template file
"""
parameters = self.listFields(template)
self._findMissingParams(parameters, **kwargs) | python | def _checkMissingParams(self, template, **kwargs):
"""Check the missing parameters for rendering from the template file
"""
parameters = self.listFields(template)
self._findMissingParams(parameters, **kwargs) | [
"def",
"_checkMissingParams",
"(",
"self",
",",
"template",
",",
"*",
"*",
"kwargs",
")",
":",
"parameters",
"=",
"self",
".",
"listFields",
"(",
"template",
")",
"self",
".",
"_findMissingParams",
"(",
"parameters",
",",
"*",
"*",
"kwargs",
")"
] | Check the missing parameters for rendering from the template file | [
"Check",
"the",
"missing",
"parameters",
"for",
"rendering",
"from",
"the",
"template",
"file"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L1136-L1141 |
43,241 | dixudx/rtcclient | rtcclient/client.py | RTCClient._checkMissingParamsFromWorkitem | def _checkMissingParamsFromWorkitem(self, copied_from, keep=False,
**kwargs):
"""Check the missing parameters for rendering directly from the
copied workitem
"""
parameters = self.listFieldsFromWorkitem(copied_from,
... | python | def _checkMissingParamsFromWorkitem(self, copied_from, keep=False,
**kwargs):
"""Check the missing parameters for rendering directly from the
copied workitem
"""
parameters = self.listFieldsFromWorkitem(copied_from,
... | [
"def",
"_checkMissingParamsFromWorkitem",
"(",
"self",
",",
"copied_from",
",",
"keep",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"parameters",
"=",
"self",
".",
"listFieldsFromWorkitem",
"(",
"copied_from",
",",
"keep",
"=",
"keep",
")",
"self",
".",... | Check the missing parameters for rendering directly from the
copied workitem | [
"Check",
"the",
"missing",
"parameters",
"for",
"rendering",
"directly",
"from",
"the",
"copied",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L1143-L1151 |
43,242 | dixudx/rtcclient | rtcclient/client.py | RTCClient.queryWorkitems | def queryWorkitems(self, query_str, projectarea_id=None,
projectarea_name=None, returned_properties=None,
archived=False):
"""Query workitems with the query string in a certain project area
At least either of `projectarea_id` and `projectarea_name` is given... | python | def queryWorkitems(self, query_str, projectarea_id=None,
projectarea_name=None, returned_properties=None,
archived=False):
"""Query workitems with the query string in a certain project area
At least either of `projectarea_id` and `projectarea_name` is given... | [
"def",
"queryWorkitems",
"(",
"self",
",",
"query_str",
",",
"projectarea_id",
"=",
"None",
",",
"projectarea_name",
"=",
"None",
",",
"returned_properties",
"=",
"None",
",",
"archived",
"=",
"False",
")",
":",
"rp",
"=",
"returned_properties",
"return",
"sel... | Query workitems with the query string in a certain project area
At least either of `projectarea_id` and `projectarea_name` is given
:param query_str: a valid query string
:param projectarea_id: the :class:`rtcclient.project_area.ProjectArea`
id
:param projectarea_name: the ... | [
"Query",
"workitems",
"with",
"the",
"query",
"string",
"in",
"a",
"certain",
"project",
"area"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L1486-L1510 |
43,243 | dixudx/rtcclient | rtcclient/workitem.py | Workitem.addComment | def addComment(self, msg=None):
"""Add a comment to this workitem
:param msg: comment message
:return: the :class:`rtcclient.models.Comment` object
:rtype: rtcclient.models.Comment
"""
origin_comment = '''
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-... | python | def addComment(self, msg=None):
"""Add a comment to this workitem
:param msg: comment message
:return: the :class:`rtcclient.models.Comment` object
:rtype: rtcclient.models.Comment
"""
origin_comment = '''
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-... | [
"def",
"addComment",
"(",
"self",
",",
"msg",
"=",
"None",
")",
":",
"origin_comment",
"=",
"'''\n<rdf:RDF\n xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n xmlns:rtc_ext=\"http://jazz.net/xmlns/prod/jazz/rtc/ext/1.0/\"\n xmlns:rtc_cm=\"http://jazz.net/xmlns/prod/jazz/rt... | Add a comment to this workitem
:param msg: comment message
:return: the :class:`rtcclient.models.Comment` object
:rtype: rtcclient.models.Comment | [
"Add",
"a",
"comment",
"to",
"this",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L79-L137 |
43,244 | dixudx/rtcclient | rtcclient/workitem.py | Workitem.addSubscriber | def addSubscriber(self, email):
"""Add a subscriber to this workitem
If the subscriber has already been added, no more actions will be
performed.
:param email: the subscriber's email
"""
headers, raw_data = self._perform_subscribe()
existed_flag, raw_data = sel... | python | def addSubscriber(self, email):
"""Add a subscriber to this workitem
If the subscriber has already been added, no more actions will be
performed.
:param email: the subscriber's email
"""
headers, raw_data = self._perform_subscribe()
existed_flag, raw_data = sel... | [
"def",
"addSubscriber",
"(",
"self",
",",
"email",
")",
":",
"headers",
",",
"raw_data",
"=",
"self",
".",
"_perform_subscribe",
"(",
")",
"existed_flag",
",",
"raw_data",
"=",
"self",
".",
"_add_subscriber",
"(",
"email",
",",
"raw_data",
")",
"if",
"exis... | Add a subscriber to this workitem
If the subscriber has already been added, no more actions will be
performed.
:param email: the subscriber's email | [
"Add",
"a",
"subscriber",
"to",
"this",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L139-L155 |
43,245 | dixudx/rtcclient | rtcclient/workitem.py | Workitem.addSubscribers | def addSubscribers(self, emails_list):
"""Add subscribers to this workitem
If the subscribers have already been added, no more actions will be
performed.
:param emails_list: a :class:`list`/:class:`tuple`/:class:`set`
contains the the subscribers' emails
"""
... | python | def addSubscribers(self, emails_list):
"""Add subscribers to this workitem
If the subscribers have already been added, no more actions will be
performed.
:param emails_list: a :class:`list`/:class:`tuple`/:class:`set`
contains the the subscribers' emails
"""
... | [
"def",
"addSubscribers",
"(",
"self",
",",
"emails_list",
")",
":",
"if",
"not",
"hasattr",
"(",
"emails_list",
",",
"\"__iter__\"",
")",
":",
"error_msg",
"=",
"\"Input parameter 'emails_list' is not iterable\"",
"self",
".",
"log",
".",
"error",
"(",
"error_msg"... | Add subscribers to this workitem
If the subscribers have already been added, no more actions will be
performed.
:param emails_list: a :class:`list`/:class:`tuple`/:class:`set`
contains the the subscribers' emails | [
"Add",
"subscribers",
"to",
"this",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L157-L185 |
43,246 | dixudx/rtcclient | rtcclient/workitem.py | Workitem.removeSubscriber | def removeSubscriber(self, email):
"""Remove a subscriber from this workitem
If the subscriber has not been added, no more actions will be
performed.
:param email: the subscriber's email
"""
headers, raw_data = self._perform_subscribe()
missing_flag, raw_data =... | python | def removeSubscriber(self, email):
"""Remove a subscriber from this workitem
If the subscriber has not been added, no more actions will be
performed.
:param email: the subscriber's email
"""
headers, raw_data = self._perform_subscribe()
missing_flag, raw_data =... | [
"def",
"removeSubscriber",
"(",
"self",
",",
"email",
")",
":",
"headers",
",",
"raw_data",
"=",
"self",
".",
"_perform_subscribe",
"(",
")",
"missing_flag",
",",
"raw_data",
"=",
"self",
".",
"_remove_subscriber",
"(",
"email",
",",
"raw_data",
")",
"if",
... | Remove a subscriber from this workitem
If the subscriber has not been added, no more actions will be
performed.
:param email: the subscriber's email | [
"Remove",
"a",
"subscriber",
"from",
"this",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L187-L203 |
43,247 | dixudx/rtcclient | rtcclient/workitem.py | Workitem.removeSubscribers | def removeSubscribers(self, emails_list):
"""Remove subscribers from this workitem
If the subscribers have not been added, no more actions will be
performed.
:param emails_list: a :class:`list`/:class:`tuple`/:class:`set`
contains the the subscribers' emails
"""
... | python | def removeSubscribers(self, emails_list):
"""Remove subscribers from this workitem
If the subscribers have not been added, no more actions will be
performed.
:param emails_list: a :class:`list`/:class:`tuple`/:class:`set`
contains the the subscribers' emails
"""
... | [
"def",
"removeSubscribers",
"(",
"self",
",",
"emails_list",
")",
":",
"if",
"not",
"hasattr",
"(",
"emails_list",
",",
"\"__iter__\"",
")",
":",
"error_msg",
"=",
"\"Input parameter 'emails_list' is not iterable\"",
"self",
".",
"log",
".",
"error",
"(",
"error_m... | Remove subscribers from this workitem
If the subscribers have not been added, no more actions will be
performed.
:param emails_list: a :class:`list`/:class:`tuple`/:class:`set`
contains the the subscribers' emails | [
"Remove",
"subscribers",
"from",
"this",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L205-L233 |
43,248 | dixudx/rtcclient | rtcclient/workitem.py | Workitem.getParent | def getParent(self, returned_properties=None):
"""Get the parent workitem of this workitem
If no parent, None will be returned.
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:return: a :... | python | def getParent(self, returned_properties=None):
"""Get the parent workitem of this workitem
If no parent, None will be returned.
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:return: a :... | [
"def",
"getParent",
"(",
"self",
",",
"returned_properties",
"=",
"None",
")",
":",
"parent_tag",
"=",
"(",
"\"rtc_cm:com.ibm.team.workitem.linktype.\"",
"\"parentworkitem.parent\"",
")",
"rp",
"=",
"returned_properties",
"parent",
"=",
"(",
"self",
".",
"rtc_obj",
... | Get the parent workitem of this workitem
If no parent, None will be returned.
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:return: a :class:`rtcclient.workitem.Workitem` object
:rtype:... | [
"Get",
"the",
"parent",
"workitem",
"of",
"this",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L454-L479 |
43,249 | dixudx/rtcclient | rtcclient/workitem.py | Workitem.getChildren | def getChildren(self, returned_properties=None):
"""Get all the children workitems of this workitem
If no children, None will be returned.
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:... | python | def getChildren(self, returned_properties=None):
"""Get all the children workitems of this workitem
If no children, None will be returned.
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:... | [
"def",
"getChildren",
"(",
"self",
",",
"returned_properties",
"=",
"None",
")",
":",
"children_tag",
"=",
"(",
"\"rtc_cm:com.ibm.team.workitem.linktype.\"",
"\"parentworkitem.children\"",
")",
"rp",
"=",
"returned_properties",
"return",
"(",
"self",
".",
"rtc_obj",
"... | Get all the children workitems of this workitem
If no children, None will be returned.
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:return: a :class:`rtcclient.workitem.Workitem` object
... | [
"Get",
"all",
"the",
"children",
"workitems",
"of",
"this",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L481-L500 |
43,250 | dixudx/rtcclient | rtcclient/workitem.py | Workitem.getChangeSets | def getChangeSets(self):
"""Get all the ChangeSets of this workitem
:return: a :class:`list` contains all the
:class:`rtcclient.models.ChangeSet` objects
:rtype: list
"""
changeset_tag = ("rtc_cm:com.ibm.team.filesystem.workitems."
"change_s... | python | def getChangeSets(self):
"""Get all the ChangeSets of this workitem
:return: a :class:`list` contains all the
:class:`rtcclient.models.ChangeSet` objects
:rtype: list
"""
changeset_tag = ("rtc_cm:com.ibm.team.filesystem.workitems."
"change_s... | [
"def",
"getChangeSets",
"(",
"self",
")",
":",
"changeset_tag",
"=",
"(",
"\"rtc_cm:com.ibm.team.filesystem.workitems.\"",
"\"change_set.com.ibm.team.scm.ChangeSet\"",
")",
"return",
"(",
"self",
".",
"rtc_obj",
".",
"_get_paged_resources",
"(",
"\"ChangeSet\"",
",",
"wor... | Get all the ChangeSets of this workitem
:return: a :class:`list` contains all the
:class:`rtcclient.models.ChangeSet` objects
:rtype: list | [
"Get",
"all",
"the",
"ChangeSets",
"of",
"this",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L502-L516 |
43,251 | dixudx/rtcclient | rtcclient/workitem.py | Workitem.addParent | def addParent(self, parent_id):
"""Add a parent to current workitem
Notice: for a certain workitem, no more than one parent workitem
can be added and specified
:param parent_id: the parent workitem id/number
(integer or equivalent string)
"""
if isinstance(... | python | def addParent(self, parent_id):
"""Add a parent to current workitem
Notice: for a certain workitem, no more than one parent workitem
can be added and specified
:param parent_id: the parent workitem id/number
(integer or equivalent string)
"""
if isinstance(... | [
"def",
"addParent",
"(",
"self",
",",
"parent_id",
")",
":",
"if",
"isinstance",
"(",
"parent_id",
",",
"bool",
")",
":",
"raise",
"exception",
".",
"BadValue",
"(",
"\"Please input a valid workitem id\"",
")",
"if",
"isinstance",
"(",
"parent_id",
",",
"six",... | Add a parent to current workitem
Notice: for a certain workitem, no more than one parent workitem
can be added and specified
:param parent_id: the parent workitem id/number
(integer or equivalent string) | [
"Add",
"a",
"parent",
"to",
"current",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L518-L561 |
43,252 | dixudx/rtcclient | rtcclient/workitem.py | Workitem.addChild | def addChild(self, child_id):
"""Add a child to current workitem
:param child_id: the child workitem id/number
(integer or equivalent string)
"""
self.log.debug("Try to add a child <Workitem %s> to current "
"<Workitem %s>",
chi... | python | def addChild(self, child_id):
"""Add a child to current workitem
:param child_id: the child workitem id/number
(integer or equivalent string)
"""
self.log.debug("Try to add a child <Workitem %s> to current "
"<Workitem %s>",
chi... | [
"def",
"addChild",
"(",
"self",
",",
"child_id",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Try to add a child <Workitem %s> to current \"",
"\"<Workitem %s>\"",
",",
"child_id",
",",
"self",
")",
"self",
".",
"_addChildren",
"(",
"[",
"child_id",
"]",
... | Add a child to current workitem
:param child_id: the child workitem id/number
(integer or equivalent string) | [
"Add",
"a",
"child",
"to",
"current",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L563-L578 |
43,253 | dixudx/rtcclient | rtcclient/workitem.py | Workitem.addChildren | def addChildren(self, child_ids):
"""Add children to current workitem
:param child_ids: a :class:`list` contains the children
workitem id/number (integer or equivalent string)
"""
if not hasattr(child_ids, "__iter__"):
error_msg = "Input parameter 'child_ids' is... | python | def addChildren(self, child_ids):
"""Add children to current workitem
:param child_ids: a :class:`list` contains the children
workitem id/number (integer or equivalent string)
"""
if not hasattr(child_ids, "__iter__"):
error_msg = "Input parameter 'child_ids' is... | [
"def",
"addChildren",
"(",
"self",
",",
"child_ids",
")",
":",
"if",
"not",
"hasattr",
"(",
"child_ids",
",",
"\"__iter__\"",
")",
":",
"error_msg",
"=",
"\"Input parameter 'child_ids' is not iterable\"",
"self",
".",
"log",
".",
"error",
"(",
"error_msg",
")",
... | Add children to current workitem
:param child_ids: a :class:`list` contains the children
workitem id/number (integer or equivalent string) | [
"Add",
"children",
"to",
"current",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L580-L600 |
43,254 | dixudx/rtcclient | rtcclient/workitem.py | Workitem.removeParent | def removeParent(self):
"""Remove the parent workitem from current workitem
Notice: for a certain workitem, no more than one parent workitem
can be added and specified
"""
self.log.debug("Try to remove the parent workitem from current "
"<Workitem %s>",
... | python | def removeParent(self):
"""Remove the parent workitem from current workitem
Notice: for a certain workitem, no more than one parent workitem
can be added and specified
"""
self.log.debug("Try to remove the parent workitem from current "
"<Workitem %s>",
... | [
"def",
"removeParent",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Try to remove the parent workitem from current \"",
"\"<Workitem %s>\"",
",",
"self",
")",
"headers",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"rtc_obj",
".",
"headers... | Remove the parent workitem from current workitem
Notice: for a certain workitem, no more than one parent workitem
can be added and specified | [
"Remove",
"the",
"parent",
"workitem",
"from",
"current",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L660-L689 |
43,255 | dixudx/rtcclient | rtcclient/workitem.py | Workitem.removeChild | def removeChild(self, child_id):
"""Remove a child from current workitem
:param child_id: the child workitem id/number
(integer or equivalent string)
"""
self.log.debug("Try to remove a child <Workitem %s> from current "
"<Workitem %s>",
... | python | def removeChild(self, child_id):
"""Remove a child from current workitem
:param child_id: the child workitem id/number
(integer or equivalent string)
"""
self.log.debug("Try to remove a child <Workitem %s> from current "
"<Workitem %s>",
... | [
"def",
"removeChild",
"(",
"self",
",",
"child_id",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Try to remove a child <Workitem %s> from current \"",
"\"<Workitem %s>\"",
",",
"child_id",
",",
"self",
")",
"self",
".",
"_removeChildren",
"(",
"[",
"child_i... | Remove a child from current workitem
:param child_id: the child workitem id/number
(integer or equivalent string) | [
"Remove",
"a",
"child",
"from",
"current",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L691-L706 |
43,256 | dixudx/rtcclient | rtcclient/workitem.py | Workitem.removeChildren | def removeChildren(self, child_ids):
"""Remove children from current workitem
:param child_ids: a :class:`list` contains the children
workitem id/number (integer or equivalent string)
"""
if not hasattr(child_ids, "__iter__"):
error_msg = "Input parameter 'child... | python | def removeChildren(self, child_ids):
"""Remove children from current workitem
:param child_ids: a :class:`list` contains the children
workitem id/number (integer or equivalent string)
"""
if not hasattr(child_ids, "__iter__"):
error_msg = "Input parameter 'child... | [
"def",
"removeChildren",
"(",
"self",
",",
"child_ids",
")",
":",
"if",
"not",
"hasattr",
"(",
"child_ids",
",",
"\"__iter__\"",
")",
":",
"error_msg",
"=",
"\"Input parameter 'child_ids' is not iterable\"",
"self",
".",
"log",
".",
"error",
"(",
"error_msg",
")... | Remove children from current workitem
:param child_ids: a :class:`list` contains the children
workitem id/number (integer or equivalent string) | [
"Remove",
"children",
"from",
"current",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L708-L728 |
43,257 | dixudx/rtcclient | rtcclient/workitem.py | Workitem.addAttachment | def addAttachment(self, filepath):
"""Upload attachment to a workitem
:param filepath: the attachment file path
:return: the :class:`rtcclient.models.Attachment` object
:rtype: rtcclient.models.Attachment
"""
proj_id = self.contextId
fa = self.rtc_obj.getFiledA... | python | def addAttachment(self, filepath):
"""Upload attachment to a workitem
:param filepath: the attachment file path
:return: the :class:`rtcclient.models.Attachment` object
:rtype: rtcclient.models.Attachment
"""
proj_id = self.contextId
fa = self.rtc_obj.getFiledA... | [
"def",
"addAttachment",
"(",
"self",
",",
"filepath",
")",
":",
"proj_id",
"=",
"self",
".",
"contextId",
"fa",
"=",
"self",
".",
"rtc_obj",
".",
"getFiledAgainst",
"(",
"self",
".",
"filedAgainst",
",",
"projectarea_id",
"=",
"proj_id",
")",
"fa_id",
"=",... | Upload attachment to a workitem
:param filepath: the attachment file path
:return: the :class:`rtcclient.models.Attachment` object
:rtype: rtcclient.models.Attachment | [
"Upload",
"attachment",
"to",
"a",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L760-L797 |
43,258 | lxc/python2-lxc | lxc/__init__.py | list_containers | def list_containers(active=True, defined=True,
as_object=False, config_path=None):
"""
List the containers on the system.
"""
if config_path:
if not os.path.exists(config_path):
return tuple()
try:
entries = _lxc.list_containers(active=act... | python | def list_containers(active=True, defined=True,
as_object=False, config_path=None):
"""
List the containers on the system.
"""
if config_path:
if not os.path.exists(config_path):
return tuple()
try:
entries = _lxc.list_containers(active=act... | [
"def",
"list_containers",
"(",
"active",
"=",
"True",
",",
"defined",
"=",
"True",
",",
"as_object",
"=",
"False",
",",
"config_path",
"=",
"None",
")",
":",
"if",
"config_path",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"config_path",
"... | List the containers on the system. | [
"List",
"the",
"containers",
"on",
"the",
"system",
"."
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L426-L449 |
43,259 | lxc/python2-lxc | lxc/__init__.py | attach_run_command | def attach_run_command(cmd):
"""
Run a command when attaching
Please do not call directly, this will execvp the command.
This is to be used in conjunction with the attach method
of a container.
"""
if isinstance(cmd, tuple):
return _lxc.attach_run_command(cmd)
el... | python | def attach_run_command(cmd):
"""
Run a command when attaching
Please do not call directly, this will execvp the command.
This is to be used in conjunction with the attach method
of a container.
"""
if isinstance(cmd, tuple):
return _lxc.attach_run_command(cmd)
el... | [
"def",
"attach_run_command",
"(",
"cmd",
")",
":",
"if",
"isinstance",
"(",
"cmd",
",",
"tuple",
")",
":",
"return",
"_lxc",
".",
"attach_run_command",
"(",
"cmd",
")",
"elif",
"isinstance",
"(",
"cmd",
",",
"list",
")",
":",
"return",
"_lxc",
".",
"at... | Run a command when attaching
Please do not call directly, this will execvp the command.
This is to be used in conjunction with the attach method
of a container. | [
"Run",
"a",
"command",
"when",
"attaching"
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L452-L465 |
43,260 | lxc/python2-lxc | lxc/__init__.py | arch_to_personality | def arch_to_personality(arch):
"""
Determine the process personality corresponding to the architecture
"""
if isinstance(arch, bytes):
arch = unicode(arch)
return _lxc.arch_to_personality(arch) | python | def arch_to_personality(arch):
"""
Determine the process personality corresponding to the architecture
"""
if isinstance(arch, bytes):
arch = unicode(arch)
return _lxc.arch_to_personality(arch) | [
"def",
"arch_to_personality",
"(",
"arch",
")",
":",
"if",
"isinstance",
"(",
"arch",
",",
"bytes",
")",
":",
"arch",
"=",
"unicode",
"(",
"arch",
")",
"return",
"_lxc",
".",
"arch_to_personality",
"(",
"arch",
")"
] | Determine the process personality corresponding to the architecture | [
"Determine",
"the",
"process",
"personality",
"corresponding",
"to",
"the",
"architecture"
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L479-L485 |
43,261 | lxc/python2-lxc | lxc/__init__.py | Container.add_device_net | def add_device_net(self, name, destname=None):
"""
Add network device to running container.
"""
if not self.running:
return False
if os.path.exists("/sys/class/net/%s/phy80211/name" % name):
with open("/sys/class/net/%s/phy80211/name" % name) as fd:
... | python | def add_device_net(self, name, destname=None):
"""
Add network device to running container.
"""
if not self.running:
return False
if os.path.exists("/sys/class/net/%s/phy80211/name" % name):
with open("/sys/class/net/%s/phy80211/name" % name) as fd:
... | [
"def",
"add_device_net",
"(",
"self",
",",
"name",
",",
"destname",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"running",
":",
"return",
"False",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"\"/sys/class/net/%s/phy80211/name\"",
"%",
"name",
")",
... | Add network device to running container. | [
"Add",
"network",
"device",
"to",
"running",
"container",
"."
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L157-L194 |
43,262 | lxc/python2-lxc | lxc/__init__.py | Container.append_config_item | def append_config_item(self, key, value):
"""
Append 'value' to 'key', assuming 'key' is a list.
If 'key' isn't a list, 'value' will be set as the value of 'key'.
"""
return _lxc.Container.set_config_item(self, key, value) | python | def append_config_item(self, key, value):
"""
Append 'value' to 'key', assuming 'key' is a list.
If 'key' isn't a list, 'value' will be set as the value of 'key'.
"""
return _lxc.Container.set_config_item(self, key, value) | [
"def",
"append_config_item",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"_lxc",
".",
"Container",
".",
"set_config_item",
"(",
"self",
",",
"key",
",",
"value",
")"
] | Append 'value' to 'key', assuming 'key' is a list.
If 'key' isn't a list, 'value' will be set as the value of 'key'. | [
"Append",
"value",
"to",
"key",
"assuming",
"key",
"is",
"a",
"list",
".",
"If",
"key",
"isn",
"t",
"a",
"list",
"value",
"will",
"be",
"set",
"as",
"the",
"value",
"of",
"key",
"."
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L196-L202 |
43,263 | lxc/python2-lxc | lxc/__init__.py | Container.create | def create(self, template=None, flags=0, args=()):
"""
Create a new rootfs for the container.
"template" if passed must be a valid template name.
"flags" (optional) is an integer representing the optional
create flags to be passed.
"args" (optional)... | python | def create(self, template=None, flags=0, args=()):
"""
Create a new rootfs for the container.
"template" if passed must be a valid template name.
"flags" (optional) is an integer representing the optional
create flags to be passed.
"args" (optional)... | [
"def",
"create",
"(",
"self",
",",
"template",
"=",
"None",
",",
"flags",
"=",
"0",
",",
"args",
"=",
"(",
")",
")",
":",
"if",
"isinstance",
"(",
"args",
",",
"dict",
")",
":",
"template_args",
"=",
"[",
"]",
"for",
"item",
"in",
"args",
".",
... | Create a new rootfs for the container.
"template" if passed must be a valid template name.
"flags" (optional) is an integer representing the optional
create flags to be passed.
"args" (optional) is a tuple of arguments to pass to the
template. It can also b... | [
"Create",
"a",
"new",
"rootfs",
"for",
"the",
"container",
"."
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L204-L231 |
43,264 | lxc/python2-lxc | lxc/__init__.py | Container.clone | def clone(self, newname, config_path=None, flags=0, bdevtype=None,
bdevdata=None, newsize=0, hookargs=()):
"""
Clone the current container.
"""
args = {}
args['newname'] = newname
args['flags'] = flags
args['newsize'] = newsize
args['hoo... | python | def clone(self, newname, config_path=None, flags=0, bdevtype=None,
bdevdata=None, newsize=0, hookargs=()):
"""
Clone the current container.
"""
args = {}
args['newname'] = newname
args['flags'] = flags
args['newsize'] = newsize
args['hoo... | [
"def",
"clone",
"(",
"self",
",",
"newname",
",",
"config_path",
"=",
"None",
",",
"flags",
"=",
"0",
",",
"bdevtype",
"=",
"None",
",",
"bdevdata",
"=",
"None",
",",
"newsize",
"=",
"0",
",",
"hookargs",
"=",
"(",
")",
")",
":",
"args",
"=",
"{"... | Clone the current container. | [
"Clone",
"the",
"current",
"container",
"."
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L233-L254 |
43,265 | lxc/python2-lxc | lxc/__init__.py | Container.get_cgroup_item | def get_cgroup_item(self, key):
"""
Returns the value for a given cgroup entry.
A list is returned when multiple values are set.
"""
value = _lxc.Container.get_cgroup_item(self, key)
if value is False:
return False
else:
return val... | python | def get_cgroup_item(self, key):
"""
Returns the value for a given cgroup entry.
A list is returned when multiple values are set.
"""
value = _lxc.Container.get_cgroup_item(self, key)
if value is False:
return False
else:
return val... | [
"def",
"get_cgroup_item",
"(",
"self",
",",
"key",
")",
":",
"value",
"=",
"_lxc",
".",
"Container",
".",
"get_cgroup_item",
"(",
"self",
",",
"key",
")",
"if",
"value",
"is",
"False",
":",
"return",
"False",
"else",
":",
"return",
"value",
".",
"rstri... | Returns the value for a given cgroup entry.
A list is returned when multiple values are set. | [
"Returns",
"the",
"value",
"for",
"a",
"given",
"cgroup",
"entry",
".",
"A",
"list",
"is",
"returned",
"when",
"multiple",
"values",
"are",
"set",
"."
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L277-L287 |
43,266 | lxc/python2-lxc | lxc/__init__.py | Container.get_config_item | def get_config_item(self, key):
"""
Returns the value for a given config key.
A list is returned when multiple values are set.
"""
value = _lxc.Container.get_config_item(self, key)
if value is False:
return False
elif value.endswith("\n"):
... | python | def get_config_item(self, key):
"""
Returns the value for a given config key.
A list is returned when multiple values are set.
"""
value = _lxc.Container.get_config_item(self, key)
if value is False:
return False
elif value.endswith("\n"):
... | [
"def",
"get_config_item",
"(",
"self",
",",
"key",
")",
":",
"value",
"=",
"_lxc",
".",
"Container",
".",
"get_config_item",
"(",
"self",
",",
"key",
")",
"if",
"value",
"is",
"False",
":",
"return",
"False",
"elif",
"value",
".",
"endswith",
"(",
"\"\... | Returns the value for a given config key.
A list is returned when multiple values are set. | [
"Returns",
"the",
"value",
"for",
"a",
"given",
"config",
"key",
".",
"A",
"list",
"is",
"returned",
"when",
"multiple",
"values",
"are",
"set",
"."
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L289-L301 |
43,267 | lxc/python2-lxc | lxc/__init__.py | Container.get_keys | def get_keys(self, key=None):
"""
Returns a list of valid sub-keys.
"""
if key:
value = _lxc.Container.get_keys(self, key)
else:
value = _lxc.Container.get_keys(self)
if value is False:
return False
elif value.endswith("\n"... | python | def get_keys(self, key=None):
"""
Returns a list of valid sub-keys.
"""
if key:
value = _lxc.Container.get_keys(self, key)
else:
value = _lxc.Container.get_keys(self)
if value is False:
return False
elif value.endswith("\n"... | [
"def",
"get_keys",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"if",
"key",
":",
"value",
"=",
"_lxc",
".",
"Container",
".",
"get_keys",
"(",
"self",
",",
"key",
")",
"else",
":",
"value",
"=",
"_lxc",
".",
"Container",
".",
"get_keys",
"(",
... | Returns a list of valid sub-keys. | [
"Returns",
"a",
"list",
"of",
"valid",
"sub",
"-",
"keys",
"."
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L303-L317 |
43,268 | lxc/python2-lxc | lxc/__init__.py | Container.get_ips | def get_ips(self, interface=None, family=None, scope=None, timeout=0):
"""
Get a tuple of IPs for the container.
"""
kwargs = {}
if interface:
kwargs['interface'] = interface
if family:
kwargs['family'] = family
if scope:
k... | python | def get_ips(self, interface=None, family=None, scope=None, timeout=0):
"""
Get a tuple of IPs for the container.
"""
kwargs = {}
if interface:
kwargs['interface'] = interface
if family:
kwargs['family'] = family
if scope:
k... | [
"def",
"get_ips",
"(",
"self",
",",
"interface",
"=",
"None",
",",
"family",
"=",
"None",
",",
"scope",
"=",
"None",
",",
"timeout",
"=",
"0",
")",
":",
"kwargs",
"=",
"{",
"}",
"if",
"interface",
":",
"kwargs",
"[",
"'interface'",
"]",
"=",
"inter... | Get a tuple of IPs for the container. | [
"Get",
"a",
"tuple",
"of",
"IPs",
"for",
"the",
"container",
"."
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L326-L350 |
43,269 | lxc/python2-lxc | lxc/__init__.py | Container.rename | def rename(self, new_name):
"""
Rename the container.
On success, returns the new Container object.
On failure, returns False.
"""
if _lxc.Container.rename(self, new_name):
return Container(new_name)
return False | python | def rename(self, new_name):
"""
Rename the container.
On success, returns the new Container object.
On failure, returns False.
"""
if _lxc.Container.rename(self, new_name):
return Container(new_name)
return False | [
"def",
"rename",
"(",
"self",
",",
"new_name",
")",
":",
"if",
"_lxc",
".",
"Container",
".",
"rename",
"(",
"self",
",",
"new_name",
")",
":",
"return",
"Container",
"(",
"new_name",
")",
"return",
"False"
] | Rename the container.
On success, returns the new Container object.
On failure, returns False. | [
"Rename",
"the",
"container",
".",
"On",
"success",
"returns",
"the",
"new",
"Container",
"object",
".",
"On",
"failure",
"returns",
"False",
"."
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L352-L362 |
43,270 | lxc/python2-lxc | lxc/__init__.py | Container.set_config_item | def set_config_item(self, key, value):
"""
Set a config key to a provided value.
The value can be a list for the keys supporting multiple values.
"""
try:
old_value = self.get_config_item(key)
except KeyError:
old_value = None
# Ge... | python | def set_config_item(self, key, value):
"""
Set a config key to a provided value.
The value can be a list for the keys supporting multiple values.
"""
try:
old_value = self.get_config_item(key)
except KeyError:
old_value = None
# Ge... | [
"def",
"set_config_item",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"try",
":",
"old_value",
"=",
"self",
".",
"get_config_item",
"(",
"key",
")",
"except",
"KeyError",
":",
"old_value",
"=",
"None",
"# Get everything to unicode with python2",
"if",
"is... | Set a config key to a provided value.
The value can be a list for the keys supporting multiple values. | [
"Set",
"a",
"config",
"key",
"to",
"a",
"provided",
"value",
".",
"The",
"value",
"can",
"be",
"a",
"list",
"for",
"the",
"keys",
"supporting",
"multiple",
"values",
"."
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L364-L413 |
43,271 | lxc/python2-lxc | lxc/__init__.py | Container.wait | def wait(self, state, timeout=-1):
"""
Wait for the container to reach a given state or timeout.
"""
if isinstance(state, str):
state = state.upper()
return _lxc.Container.wait(self, state, timeout) | python | def wait(self, state, timeout=-1):
"""
Wait for the container to reach a given state or timeout.
"""
if isinstance(state, str):
state = state.upper()
return _lxc.Container.wait(self, state, timeout) | [
"def",
"wait",
"(",
"self",
",",
"state",
",",
"timeout",
"=",
"-",
"1",
")",
":",
"if",
"isinstance",
"(",
"state",
",",
"str",
")",
":",
"state",
"=",
"state",
".",
"upper",
"(",
")",
"return",
"_lxc",
".",
"Container",
".",
"wait",
"(",
"self"... | Wait for the container to reach a given state or timeout. | [
"Wait",
"for",
"the",
"container",
"to",
"reach",
"a",
"given",
"state",
"or",
"timeout",
"."
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L415-L423 |
43,272 | dixudx/rtcclient | rtcclient/template.py | Templater.render | def render(self, template, **kwargs):
"""Renders the template
:param template: The template to render.
The template is actually a file, which is usually generated
by :class:`rtcclient.template.Templater.getTemplate`
and can also be modified by user accordingly.
... | python | def render(self, template, **kwargs):
"""Renders the template
:param template: The template to render.
The template is actually a file, which is usually generated
by :class:`rtcclient.template.Templater.getTemplate`
and can also be modified by user accordingly.
... | [
"def",
"render",
"(",
"self",
",",
"template",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"temp",
"=",
"self",
".",
"environment",
".",
"get_template",
"(",
"template",
")",
"return",
"temp",
".",
"render",
"(",
"*",
"*",
"kwargs",
")",
"except",... | Renders the template
:param template: The template to render.
The template is actually a file, which is usually generated
by :class:`rtcclient.template.Templater.getTemplate`
and can also be modified by user accordingly.
:param kwargs: The `kwargs` dict is used to fi... | [
"Renders",
"the",
"template"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/template.py#L43-L81 |
43,273 | dixudx/rtcclient | rtcclient/template.py | Templater.listFields | def listFields(self, template):
"""List all the attributes to be rendered from the template file
:param template: The template to render.
The template is actually a file, which is usually generated
by :class:`rtcclient.template.Templater.getTemplate` and can also
be ... | python | def listFields(self, template):
"""List all the attributes to be rendered from the template file
:param template: The template to render.
The template is actually a file, which is usually generated
by :class:`rtcclient.template.Templater.getTemplate` and can also
be ... | [
"def",
"listFields",
"(",
"self",
",",
"template",
")",
":",
"try",
":",
"temp_source",
"=",
"self",
".",
"environment",
".",
"loader",
".",
"get_source",
"(",
"self",
".",
"environment",
",",
"template",
")",
"return",
"self",
".",
"listFieldsFromSource",
... | List all the attributes to be rendered from the template file
:param template: The template to render.
The template is actually a file, which is usually generated
by :class:`rtcclient.template.Templater.getTemplate` and can also
be modified by user accordingly.
:retu... | [
"List",
"all",
"the",
"attributes",
"to",
"be",
"rendered",
"from",
"the",
"template",
"file"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/template.py#L134-L152 |
43,274 | dixudx/rtcclient | rtcclient/template.py | Templater.listFieldsFromSource | def listFieldsFromSource(self, template_source):
"""List all the attributes to be rendered directly from template
source
:param template_source: the template source (usually represents the
template content in string format)
:return: a :class:`set` contains all the needed att... | python | def listFieldsFromSource(self, template_source):
"""List all the attributes to be rendered directly from template
source
:param template_source: the template source (usually represents the
template content in string format)
:return: a :class:`set` contains all the needed att... | [
"def",
"listFieldsFromSource",
"(",
"self",
",",
"template_source",
")",
":",
"ast",
"=",
"self",
".",
"environment",
".",
"parse",
"(",
"template_source",
")",
"return",
"jinja2",
".",
"meta",
".",
"find_undeclared_variables",
"(",
"ast",
")"
] | List all the attributes to be rendered directly from template
source
:param template_source: the template source (usually represents the
template content in string format)
:return: a :class:`set` contains all the needed attributes
:rtype: set | [
"List",
"all",
"the",
"attributes",
"to",
"be",
"rendered",
"directly",
"from",
"template",
"source"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/template.py#L183-L194 |
43,275 | Jaymon/dump | dump/postgres.py | Postgres._get_file | def _get_file(self):
'''
return an opened tempfile pointer that can be used
http://docs.python.org/2/library/tempfile.html
'''
f = tempfile.NamedTemporaryFile(delete=False)
self.tmp_files.add(f.name)
return f | python | def _get_file(self):
'''
return an opened tempfile pointer that can be used
http://docs.python.org/2/library/tempfile.html
'''
f = tempfile.NamedTemporaryFile(delete=False)
self.tmp_files.add(f.name)
return f | [
"def",
"_get_file",
"(",
"self",
")",
":",
"f",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"delete",
"=",
"False",
")",
"self",
".",
"tmp_files",
".",
"add",
"(",
"f",
".",
"name",
")",
"return",
"f"
] | return an opened tempfile pointer that can be used
http://docs.python.org/2/library/tempfile.html | [
"return",
"an",
"opened",
"tempfile",
"pointer",
"that",
"can",
"be",
"used"
] | 40045669e07cc2676a9fa92afcf5ef18f10f2fcc | https://github.com/Jaymon/dump/blob/40045669e07cc2676a9fa92afcf5ef18f10f2fcc/dump/postgres.py#L117-L125 |
43,276 | Jaymon/dump | dump/postgres.py | Postgres._get_args | def _get_args(self, executable, *args):
"""compile all the executable and the arguments, combining with common arguments
to create a full batch of command args"""
args = list(args)
args.insert(0, executable)
if self.username:
args.append("--username={}".format(self.us... | python | def _get_args(self, executable, *args):
"""compile all the executable and the arguments, combining with common arguments
to create a full batch of command args"""
args = list(args)
args.insert(0, executable)
if self.username:
args.append("--username={}".format(self.us... | [
"def",
"_get_args",
"(",
"self",
",",
"executable",
",",
"*",
"args",
")",
":",
"args",
"=",
"list",
"(",
"args",
")",
"args",
".",
"insert",
"(",
"0",
",",
"executable",
")",
"if",
"self",
".",
"username",
":",
"args",
".",
"append",
"(",
"\"--use... | compile all the executable and the arguments, combining with common arguments
to create a full batch of command args | [
"compile",
"all",
"the",
"executable",
"and",
"the",
"arguments",
"combining",
"with",
"common",
"arguments",
"to",
"create",
"a",
"full",
"batch",
"of",
"command",
"args"
] | 40045669e07cc2676a9fa92afcf5ef18f10f2fcc | https://github.com/Jaymon/dump/blob/40045669e07cc2676a9fa92afcf5ef18f10f2fcc/dump/postgres.py#L127-L141 |
43,277 | Jaymon/dump | dump/postgres.py | Postgres._get_outfile_path | def _get_outfile_path(self, table):
"""return the path for a file we can use to back up the table"""
self.outfile_count += 1
outfile = os.path.join(self.directory, '{:03d}_{}.sql.gz'.format(self.outfile_count, table))
return outfile | python | def _get_outfile_path(self, table):
"""return the path for a file we can use to back up the table"""
self.outfile_count += 1
outfile = os.path.join(self.directory, '{:03d}_{}.sql.gz'.format(self.outfile_count, table))
return outfile | [
"def",
"_get_outfile_path",
"(",
"self",
",",
"table",
")",
":",
"self",
".",
"outfile_count",
"+=",
"1",
"outfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"directory",
",",
"'{:03d}_{}.sql.gz'",
".",
"format",
"(",
"self",
".",
"outfile_... | return the path for a file we can use to back up the table | [
"return",
"the",
"path",
"for",
"a",
"file",
"we",
"can",
"use",
"to",
"back",
"up",
"the",
"table"
] | 40045669e07cc2676a9fa92afcf5ef18f10f2fcc | https://github.com/Jaymon/dump/blob/40045669e07cc2676a9fa92afcf5ef18f10f2fcc/dump/postgres.py#L181-L185 |
43,278 | Jaymon/dump | dump/postgres.py | Postgres._run_queries | def _run_queries(self, queries, *args, **kwargs):
"""run the queries
queries -- list -- the queries to run
return -- string -- the results of the query?
"""
# write out all the commands to a temp file and then have psql run that file
f = self._get_file()
for q in... | python | def _run_queries(self, queries, *args, **kwargs):
"""run the queries
queries -- list -- the queries to run
return -- string -- the results of the query?
"""
# write out all the commands to a temp file and then have psql run that file
f = self._get_file()
for q in... | [
"def",
"_run_queries",
"(",
"self",
",",
"queries",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# write out all the commands to a temp file and then have psql run that file",
"f",
"=",
"self",
".",
"_get_file",
"(",
")",
"for",
"q",
"in",
"queries",
":... | run the queries
queries -- list -- the queries to run
return -- string -- the results of the query? | [
"run",
"the",
"queries"
] | 40045669e07cc2676a9fa92afcf5ef18f10f2fcc | https://github.com/Jaymon/dump/blob/40045669e07cc2676a9fa92afcf5ef18f10f2fcc/dump/postgres.py#L187-L200 |
43,279 | Jaymon/dump | dump/postgres.py | Postgres._restore_auto_increment | def _restore_auto_increment(self, table):
"""restore the auto increment value for the table to what it was previously"""
query, seq_table, seq_column, seq_name = self._get_auto_increment_info(table)
if query:
queries = [query, "select nextval('{}')".format(seq_name)]
retu... | python | def _restore_auto_increment(self, table):
"""restore the auto increment value for the table to what it was previously"""
query, seq_table, seq_column, seq_name = self._get_auto_increment_info(table)
if query:
queries = [query, "select nextval('{}')".format(seq_name)]
retu... | [
"def",
"_restore_auto_increment",
"(",
"self",
",",
"table",
")",
":",
"query",
",",
"seq_table",
",",
"seq_column",
",",
"seq_name",
"=",
"self",
".",
"_get_auto_increment_info",
"(",
"table",
")",
"if",
"query",
":",
"queries",
"=",
"[",
"query",
",",
"\... | restore the auto increment value for the table to what it was previously | [
"restore",
"the",
"auto",
"increment",
"value",
"for",
"the",
"table",
"to",
"what",
"it",
"was",
"previously"
] | 40045669e07cc2676a9fa92afcf5ef18f10f2fcc | https://github.com/Jaymon/dump/blob/40045669e07cc2676a9fa92afcf5ef18f10f2fcc/dump/postgres.py#L202-L207 |
43,280 | Jaymon/dump | dump/postgres.py | Postgres._get_auto_increment_info | def _get_auto_increment_info(self, table):
"""figure out the the autoincrement value for the given table"""
query = ''
seq_table = ''
seq_column = ''
seq_name = ''
find_query = "\n".join([
"SELECT",
" t.relname as related_table,",
" a... | python | def _get_auto_increment_info(self, table):
"""figure out the the autoincrement value for the given table"""
query = ''
seq_table = ''
seq_column = ''
seq_name = ''
find_query = "\n".join([
"SELECT",
" t.relname as related_table,",
" a... | [
"def",
"_get_auto_increment_info",
"(",
"self",
",",
"table",
")",
":",
"query",
"=",
"''",
"seq_table",
"=",
"''",
"seq_column",
"=",
"''",
"seq_name",
"=",
"''",
"find_query",
"=",
"\"\\n\"",
".",
"join",
"(",
"[",
"\"SELECT\"",
",",
"\" t.relname as rela... | figure out the the autoincrement value for the given table | [
"figure",
"out",
"the",
"the",
"autoincrement",
"value",
"for",
"the",
"given",
"table"
] | 40045669e07cc2676a9fa92afcf5ef18f10f2fcc | https://github.com/Jaymon/dump/blob/40045669e07cc2676a9fa92afcf5ef18f10f2fcc/dump/postgres.py#L209-L252 |
43,281 | Jaymon/dump | dump/interface/postgres.py | Postgres.restore | def restore(self):
"""use the self.directory to restore a db
NOTE -- this will only restore a database dumped with one of the methods
of this class
"""
sql_files = []
for root, dirs, files in os.walk(self.directory):
for f in files:
if f.endsw... | python | def restore(self):
"""use the self.directory to restore a db
NOTE -- this will only restore a database dumped with one of the methods
of this class
"""
sql_files = []
for root, dirs, files in os.walk(self.directory):
for f in files:
if f.endsw... | [
"def",
"restore",
"(",
"self",
")",
":",
"sql_files",
"=",
"[",
"]",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"self",
".",
"directory",
")",
":",
"for",
"f",
"in",
"files",
":",
"if",
"f",
".",
"endswith",
"(",
"\... | use the self.directory to restore a db
NOTE -- this will only restore a database dumped with one of the methods
of this class | [
"use",
"the",
"self",
".",
"directory",
"to",
"restore",
"a",
"db"
] | 40045669e07cc2676a9fa92afcf5ef18f10f2fcc | https://github.com/Jaymon/dump/blob/40045669e07cc2676a9fa92afcf5ef18f10f2fcc/dump/interface/postgres.py#L58-L90 |
43,282 | Jaymon/dump | dump/interface/postgres.py | Postgres._get_env | def _get_env(self):
"""this returns an environment dictionary we want to use to run the command
this will also create a fake pgpass file in order to make it possible for
the script to be passwordless"""
if hasattr(self, 'env'): return self.env
# create a temporary pgpass file
... | python | def _get_env(self):
"""this returns an environment dictionary we want to use to run the command
this will also create a fake pgpass file in order to make it possible for
the script to be passwordless"""
if hasattr(self, 'env'): return self.env
# create a temporary pgpass file
... | [
"def",
"_get_env",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'env'",
")",
":",
"return",
"self",
".",
"env",
"# create a temporary pgpass file",
"pgpass",
"=",
"self",
".",
"_get_file",
"(",
")",
"# format: http://www.postgresql.org/docs/9.2/stati... | this returns an environment dictionary we want to use to run the command
this will also create a fake pgpass file in order to make it possible for
the script to be passwordless | [
"this",
"returns",
"an",
"environment",
"dictionary",
"we",
"want",
"to",
"use",
"to",
"run",
"the",
"command"
] | 40045669e07cc2676a9fa92afcf5ef18f10f2fcc | https://github.com/Jaymon/dump/blob/40045669e07cc2676a9fa92afcf5ef18f10f2fcc/dump/interface/postgres.py#L144-L161 |
43,283 | thomwiggers/httpserver | httpserver/httpserver.py | _get_response | def _get_response(**kwargs):
"""Get a template response
Use kwargs to add things to the dictionary
"""
if 'code' not in kwargs:
kwargs['code'] = 200
if 'headers' not in kwargs:
kwargs['headers'] = dict()
if 'version' not in kwargs:
kwargs['version'] = 'HTTP/1.1'
ret... | python | def _get_response(**kwargs):
"""Get a template response
Use kwargs to add things to the dictionary
"""
if 'code' not in kwargs:
kwargs['code'] = 200
if 'headers' not in kwargs:
kwargs['headers'] = dict()
if 'version' not in kwargs:
kwargs['version'] = 'HTTP/1.1'
ret... | [
"def",
"_get_response",
"(",
"*",
"*",
"kwargs",
")",
":",
"if",
"'code'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'code'",
"]",
"=",
"200",
"if",
"'headers'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'headers'",
"]",
"=",
"dict",
"(",
")",
... | Get a template response
Use kwargs to add things to the dictionary | [
"Get",
"a",
"template",
"response"
] | 88a3a35619ce5185347c6764f211878e898e6aad | https://github.com/thomwiggers/httpserver/blob/88a3a35619ce5185347c6764f211878e898e6aad/httpserver/httpserver.py#L16-L28 |
43,284 | thomwiggers/httpserver | httpserver/httpserver.py | HttpProtocol._write_transport | def _write_transport(self, string):
"""Convenience function to write to the transport"""
if isinstance(string, str): # we need to convert to bytes
self.transport.write(string.encode('utf-8'))
else:
self.transport.write(string) | python | def _write_transport(self, string):
"""Convenience function to write to the transport"""
if isinstance(string, str): # we need to convert to bytes
self.transport.write(string.encode('utf-8'))
else:
self.transport.write(string) | [
"def",
"_write_transport",
"(",
"self",
",",
"string",
")",
":",
"if",
"isinstance",
"(",
"string",
",",
"str",
")",
":",
"# we need to convert to bytes",
"self",
".",
"transport",
".",
"write",
"(",
"string",
".",
"encode",
"(",
"'utf-8'",
")",
")",
"else... | Convenience function to write to the transport | [
"Convenience",
"function",
"to",
"write",
"to",
"the",
"transport"
] | 88a3a35619ce5185347c6764f211878e898e6aad | https://github.com/thomwiggers/httpserver/blob/88a3a35619ce5185347c6764f211878e898e6aad/httpserver/httpserver.py#L52-L57 |
43,285 | thomwiggers/httpserver | httpserver/httpserver.py | HttpProtocol._write_response | def _write_response(self, response):
"""Write the response back to the client
Arguments:
response -- the dictionary containing the response.
"""
status = '{} {} {}\r\n'.format(response['version'],
response['code'],
... | python | def _write_response(self, response):
"""Write the response back to the client
Arguments:
response -- the dictionary containing the response.
"""
status = '{} {} {}\r\n'.format(response['version'],
response['code'],
... | [
"def",
"_write_response",
"(",
"self",
",",
"response",
")",
":",
"status",
"=",
"'{} {} {}\\r\\n'",
".",
"format",
"(",
"response",
"[",
"'version'",
"]",
",",
"response",
"[",
"'code'",
"]",
",",
"responses",
"[",
"response",
"[",
"'code'",
"]",
"]",
"... | Write the response back to the client
Arguments:
response -- the dictionary containing the response. | [
"Write",
"the",
"response",
"back",
"to",
"the",
"client"
] | 88a3a35619ce5185347c6764f211878e898e6aad | https://github.com/thomwiggers/httpserver/blob/88a3a35619ce5185347c6764f211878e898e6aad/httpserver/httpserver.py#L59-L83 |
43,286 | thomwiggers/httpserver | httpserver/httpserver.py | HttpProtocol.connection_made | def connection_made(self, transport):
"""Called when the connection is made"""
self.logger.info('Connection made at object %s', id(self))
self.transport = transport
self.keepalive = True
if self._timeout:
self.logger.debug('Registering timeout event')
sel... | python | def connection_made(self, transport):
"""Called when the connection is made"""
self.logger.info('Connection made at object %s', id(self))
self.transport = transport
self.keepalive = True
if self._timeout:
self.logger.debug('Registering timeout event')
sel... | [
"def",
"connection_made",
"(",
"self",
",",
"transport",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'Connection made at object %s'",
",",
"id",
"(",
"self",
")",
")",
"self",
".",
"transport",
"=",
"transport",
"self",
".",
"keepalive",
"=",
"True... | Called when the connection is made | [
"Called",
"when",
"the",
"connection",
"is",
"made"
] | 88a3a35619ce5185347c6764f211878e898e6aad | https://github.com/thomwiggers/httpserver/blob/88a3a35619ce5185347c6764f211878e898e6aad/httpserver/httpserver.py#L85-L94 |
43,287 | thomwiggers/httpserver | httpserver/httpserver.py | HttpProtocol.connection_lost | def connection_lost(self, exception):
"""Called when the connection is lost or closed.
The argument is either an exception object or None. The latter means
a regular EOF is received, or the connection was aborted or closed by
this side of the connection.
"""
if exception... | python | def connection_lost(self, exception):
"""Called when the connection is lost or closed.
The argument is either an exception object or None. The latter means
a regular EOF is received, or the connection was aborted or closed by
this side of the connection.
"""
if exception... | [
"def",
"connection_lost",
"(",
"self",
",",
"exception",
")",
":",
"if",
"exception",
":",
"self",
".",
"logger",
".",
"exception",
"(",
"'Connection lost!'",
")",
"else",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'Connection lost'",
")"
] | Called when the connection is lost or closed.
The argument is either an exception object or None. The latter means
a regular EOF is received, or the connection was aborted or closed by
this side of the connection. | [
"Called",
"when",
"the",
"connection",
"is",
"lost",
"or",
"closed",
"."
] | 88a3a35619ce5185347c6764f211878e898e6aad | https://github.com/thomwiggers/httpserver/blob/88a3a35619ce5185347c6764f211878e898e6aad/httpserver/httpserver.py#L96-L106 |
43,288 | thomwiggers/httpserver | httpserver/httpserver.py | HttpProtocol.data_received | def data_received(self, data):
"""Process received data from the socket
Called when we receive data
"""
self.logger.debug('Received data: %s', repr(data))
try:
request = self._parse_headers(data)
self._handle_request(request)
except InvalidReques... | python | def data_received(self, data):
"""Process received data from the socket
Called when we receive data
"""
self.logger.debug('Received data: %s', repr(data))
try:
request = self._parse_headers(data)
self._handle_request(request)
except InvalidReques... | [
"def",
"data_received",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Received data: %s'",
",",
"repr",
"(",
"data",
")",
")",
"try",
":",
"request",
"=",
"self",
".",
"_parse_headers",
"(",
"data",
")",
"self",
".",
... | Process received data from the socket
Called when we receive data | [
"Process",
"received",
"data",
"from",
"the",
"socket"
] | 88a3a35619ce5185347c6764f211878e898e6aad | https://github.com/thomwiggers/httpserver/blob/88a3a35619ce5185347c6764f211878e898e6aad/httpserver/httpserver.py#L108-L130 |
43,289 | thomwiggers/httpserver | httpserver/httpserver.py | HttpProtocol._get_request_uri | def _get_request_uri(self, request):
"""Parse the request URI into something useful
Server MUST accept full URIs (5.1.2)"""
request_uri = request['target']
if request_uri.startswith('/'): # eg. GET /index.html
return (request.get('Host', 'localhost').split(':')[0],
... | python | def _get_request_uri(self, request):
"""Parse the request URI into something useful
Server MUST accept full URIs (5.1.2)"""
request_uri = request['target']
if request_uri.startswith('/'): # eg. GET /index.html
return (request.get('Host', 'localhost').split(':')[0],
... | [
"def",
"_get_request_uri",
"(",
"self",
",",
"request",
")",
":",
"request_uri",
"=",
"request",
"[",
"'target'",
"]",
"if",
"request_uri",
".",
"startswith",
"(",
"'/'",
")",
":",
"# eg. GET /index.html",
"return",
"(",
"request",
".",
"get",
"(",
"'Host'",... | Parse the request URI into something useful
Server MUST accept full URIs (5.1.2) | [
"Parse",
"the",
"request",
"URI",
"into",
"something",
"useful"
] | 88a3a35619ce5185347c6764f211878e898e6aad | https://github.com/thomwiggers/httpserver/blob/88a3a35619ce5185347c6764f211878e898e6aad/httpserver/httpserver.py#L173-L184 |
43,290 | thomwiggers/httpserver | httpserver/httpserver.py | HttpProtocol._handle_request | def _handle_request(self, request):
"""Process the headers and get the file"""
# Check if this is a persistent connection.
if request['version'] == 'HTTP/1.1':
self.keepalive = not request.get('Connection') == 'close'
elif request['version'] == 'HTTP/1.0':
self.k... | python | def _handle_request(self, request):
"""Process the headers and get the file"""
# Check if this is a persistent connection.
if request['version'] == 'HTTP/1.1':
self.keepalive = not request.get('Connection') == 'close'
elif request['version'] == 'HTTP/1.0':
self.k... | [
"def",
"_handle_request",
"(",
"self",
",",
"request",
")",
":",
"# Check if this is a persistent connection.",
"if",
"request",
"[",
"'version'",
"]",
"==",
"'HTTP/1.1'",
":",
"self",
".",
"keepalive",
"=",
"not",
"request",
".",
"get",
"(",
"'Connection'",
")"... | Process the headers and get the file | [
"Process",
"the",
"headers",
"and",
"get",
"the",
"file"
] | 88a3a35619ce5185347c6764f211878e898e6aad | https://github.com/thomwiggers/httpserver/blob/88a3a35619ce5185347c6764f211878e898e6aad/httpserver/httpserver.py#L186-L257 |
43,291 | thomwiggers/httpserver | httpserver/httpserver.py | InvalidRequestError.get_http_response | def get_http_response(self):
"""Get this exception as an HTTP response suitable for output"""
return _get_response(
code=self.code,
body=str(self),
headers={
'Content-Type': 'text/plain'
}
) | python | def get_http_response(self):
"""Get this exception as an HTTP response suitable for output"""
return _get_response(
code=self.code,
body=str(self),
headers={
'Content-Type': 'text/plain'
}
) | [
"def",
"get_http_response",
"(",
"self",
")",
":",
"return",
"_get_response",
"(",
"code",
"=",
"self",
".",
"code",
",",
"body",
"=",
"str",
"(",
"self",
")",
",",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'text/plain'",
"}",
")"
] | Get this exception as an HTTP response suitable for output | [
"Get",
"this",
"exception",
"as",
"an",
"HTTP",
"response",
"suitable",
"for",
"output"
] | 88a3a35619ce5185347c6764f211878e898e6aad | https://github.com/thomwiggers/httpserver/blob/88a3a35619ce5185347c6764f211878e898e6aad/httpserver/httpserver.py#L280-L288 |
43,292 | thomwiggers/httpserver | httpserver/__init__.py | _start_server | def _start_server(bindaddr, port, hostname, folder):
"""Starts an asyncio server"""
import asyncio
from .httpserver import HttpProtocol
loop = asyncio.get_event_loop()
coroutine = loop.create_server(lambda: HttpProtocol(hostname, folder),
bindaddr,
... | python | def _start_server(bindaddr, port, hostname, folder):
"""Starts an asyncio server"""
import asyncio
from .httpserver import HttpProtocol
loop = asyncio.get_event_loop()
coroutine = loop.create_server(lambda: HttpProtocol(hostname, folder),
bindaddr,
... | [
"def",
"_start_server",
"(",
"bindaddr",
",",
"port",
",",
"hostname",
",",
"folder",
")",
":",
"import",
"asyncio",
"from",
".",
"httpserver",
"import",
"HttpProtocol",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"coroutine",
"=",
"loop",
".",
... | Starts an asyncio server | [
"Starts",
"an",
"asyncio",
"server"
] | 88a3a35619ce5185347c6764f211878e898e6aad | https://github.com/thomwiggers/httpserver/blob/88a3a35619ce5185347c6764f211878e898e6aad/httpserver/__init__.py#L11-L25 |
43,293 | thomwiggers/httpserver | httpserver/__init__.py | run | def run(argv=None): # pragma: no cover
"""Run the HTTP server
Usage:
httpserver [options] [<folder>]
Options::
-h,--host=<hostname> What host name to serve (default localhost)
-a,--bindaddress=<address> Address to bind to (default 127.0.0.1)
-p,--port=<port> ... | python | def run(argv=None): # pragma: no cover
"""Run the HTTP server
Usage:
httpserver [options] [<folder>]
Options::
-h,--host=<hostname> What host name to serve (default localhost)
-a,--bindaddress=<address> Address to bind to (default 127.0.0.1)
-p,--port=<port> ... | [
"def",
"run",
"(",
"argv",
"=",
"None",
")",
":",
"# pragma: no cover",
"import",
"sys",
"import",
"os",
"import",
"docopt",
"import",
"textwrap",
"# Check for the version",
"if",
"not",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
"4",
")",
":",
"prin... | Run the HTTP server
Usage:
httpserver [options] [<folder>]
Options::
-h,--host=<hostname> What host name to serve (default localhost)
-a,--bindaddress=<address> Address to bind to (default 127.0.0.1)
-p,--port=<port> Port to listen on (default 8080)
... | [
"Run",
"the",
"HTTP",
"server"
] | 88a3a35619ce5185347c6764f211878e898e6aad | https://github.com/thomwiggers/httpserver/blob/88a3a35619ce5185347c6764f211878e898e6aad/httpserver/__init__.py#L28-L85 |
43,294 | dslackw/slpkg | slpkg/url_read.py | URL.reading | def reading(self):
"""Open url and read
"""
try:
# testing proxy
proxies = {}
try:
proxies["http_proxy"] = os.environ['http_proxy']
except KeyError:
pass
try:
proxies["https_proxy"] = os.e... | python | def reading(self):
"""Open url and read
"""
try:
# testing proxy
proxies = {}
try:
proxies["http_proxy"] = os.environ['http_proxy']
except KeyError:
pass
try:
proxies["https_proxy"] = os.e... | [
"def",
"reading",
"(",
"self",
")",
":",
"try",
":",
"# testing proxy",
"proxies",
"=",
"{",
"}",
"try",
":",
"proxies",
"[",
"\"http_proxy\"",
"]",
"=",
"os",
".",
"environ",
"[",
"'http_proxy'",
"]",
"except",
"KeyError",
":",
"pass",
"try",
":",
"pr... | Open url and read | [
"Open",
"url",
"and",
"read"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/url_read.py#L38-L65 |
43,295 | dslackw/slpkg | slpkg/repolist.py | RepoList.repos | def repos(self):
"""View or enabled or disabled repositories
"""
def_cnt, cus_cnt = 0, 0
print("")
self.msg.template(78)
print("{0}{1}{2}{3}{4}{5}{6}".format(
"| Repo id", " " * 2,
"Repo URL", " " * 44,
"Default", " " * 3,
"... | python | def repos(self):
"""View or enabled or disabled repositories
"""
def_cnt, cus_cnt = 0, 0
print("")
self.msg.template(78)
print("{0}{1}{2}{3}{4}{5}{6}".format(
"| Repo id", " " * 2,
"Repo URL", " " * 44,
"Default", " " * 3,
"... | [
"def",
"repos",
"(",
"self",
")",
":",
"def_cnt",
",",
"cus_cnt",
"=",
"0",
",",
"0",
"print",
"(",
"\"\"",
")",
"self",
".",
"msg",
".",
"template",
"(",
"78",
")",
"print",
"(",
"\"{0}{1}{2}{3}{4}{5}{6}\"",
".",
"format",
"(",
"\"| Repo id\"",
",",
... | View or enabled or disabled repositories | [
"View",
"or",
"enabled",
"or",
"disabled",
"repositories"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/repolist.py#L40-L76 |
43,296 | dslackw/slpkg | slpkg/config.py | Config.view | def view(self):
"""View slpkg config file
"""
print("") # new line at start
conf_args = [
"RELEASE",
"SLACKWARE_VERSION",
"COMP_ARCH",
"BUILD_PATH",
"PACKAGES",
"PATCHES",
"CHECKMD5",
"DEL_A... | python | def view(self):
"""View slpkg config file
"""
print("") # new line at start
conf_args = [
"RELEASE",
"SLACKWARE_VERSION",
"COMP_ARCH",
"BUILD_PATH",
"PACKAGES",
"PATCHES",
"CHECKMD5",
"DEL_A... | [
"def",
"view",
"(",
"self",
")",
":",
"print",
"(",
"\"\"",
")",
"# new line at start",
"conf_args",
"=",
"[",
"\"RELEASE\"",
",",
"\"SLACKWARE_VERSION\"",
",",
"\"COMP_ARCH\"",
",",
"\"BUILD_PATH\"",
",",
"\"PACKAGES\"",
",",
"\"PATCHES\"",
",",
"\"CHECKMD5\"",
... | View slpkg config file | [
"View",
"slpkg",
"config",
"file"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/config.py#L40-L77 |
43,297 | dslackw/slpkg | slpkg/config.py | Config.edit | def edit(self):
"""Edit configuration file
"""
subprocess.call("{0} {1}".format(self.meta.editor,
self.config_file), shell=True) | python | def edit(self):
"""Edit configuration file
"""
subprocess.call("{0} {1}".format(self.meta.editor,
self.config_file), shell=True) | [
"def",
"edit",
"(",
"self",
")",
":",
"subprocess",
".",
"call",
"(",
"\"{0} {1}\"",
".",
"format",
"(",
"self",
".",
"meta",
".",
"editor",
",",
"self",
".",
"config_file",
")",
",",
"shell",
"=",
"True",
")"
] | Edit configuration file | [
"Edit",
"configuration",
"file"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/config.py#L79-L83 |
43,298 | dslackw/slpkg | slpkg/config.py | Config.reset | def reset(self):
"""Reset slpkg.conf file with default values
"""
shutil.copy2(self.config_file + ".orig", self.config_file)
if filecmp.cmp(self.config_file + ".orig", self.config_file):
print("{0}The reset was done{1}".format(
self.meta.color["GREEN"], self.m... | python | def reset(self):
"""Reset slpkg.conf file with default values
"""
shutil.copy2(self.config_file + ".orig", self.config_file)
if filecmp.cmp(self.config_file + ".orig", self.config_file):
print("{0}The reset was done{1}".format(
self.meta.color["GREEN"], self.m... | [
"def",
"reset",
"(",
"self",
")",
":",
"shutil",
".",
"copy2",
"(",
"self",
".",
"config_file",
"+",
"\".orig\"",
",",
"self",
".",
"config_file",
")",
"if",
"filecmp",
".",
"cmp",
"(",
"self",
".",
"config_file",
"+",
"\".orig\"",
",",
"self",
".",
... | Reset slpkg.conf file with default values | [
"Reset",
"slpkg",
".",
"conf",
"file",
"with",
"default",
"values"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/config.py#L85-L94 |
43,299 | dslackw/slpkg | slpkg/sbo/sbo_arch.py | SBoArch.get | def get(self):
"""Return sbo arch
"""
if self.arch.startswith("i") and self.arch.endswith("86"):
self.arch = self.x86
elif self.meta.arch.startswith("arm"):
self.arch = self.arm
return self.arch | python | def get(self):
"""Return sbo arch
"""
if self.arch.startswith("i") and self.arch.endswith("86"):
self.arch = self.x86
elif self.meta.arch.startswith("arm"):
self.arch = self.arm
return self.arch | [
"def",
"get",
"(",
"self",
")",
":",
"if",
"self",
".",
"arch",
".",
"startswith",
"(",
"\"i\"",
")",
"and",
"self",
".",
"arch",
".",
"endswith",
"(",
"\"86\"",
")",
":",
"self",
".",
"arch",
"=",
"self",
".",
"x86",
"elif",
"self",
".",
"meta",... | Return sbo arch | [
"Return",
"sbo",
"arch"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/sbo_arch.py#L38-L45 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.