Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
Element.getAttribute | (self, name, ns=None, default=None) |
Get an attribute by name and (optional) namespace
@param name: The name of a contained attribute (may contain prefix).
@type name: basestring
@param ns: An optional namespace
@type ns: (I{prefix}, I{name})
@param default: Returned when attribute not-found.
@type ... |
Get an attribute by name and (optional) namespace
| def getAttribute(self, name, ns=None, default=None):
"""
Get an attribute by name and (optional) namespace
@param name: The name of a contained attribute (may contain prefix).
@type name: basestring
@param ns: An optional namespace
@type ns: (I{prefix}, I{name})
@... | [
"def",
"getAttribute",
"(",
"self",
",",
"name",
",",
"ns",
"=",
"None",
",",
"default",
"=",
"None",
")",
":",
"if",
"ns",
"is",
"None",
":",
"prefix",
",",
"name",
"=",
"splitPrefix",
"(",
"name",
")",
"if",
"prefix",
"is",
"None",
":",
"ns",
"... | [
390,
4
] | [
411,
22
] | python | en | ['en', 'error', 'th'] | False |
Element.getChild | (self, name, ns=None, default=None) |
Get a child by (optional) name and/or (optional) namespace.
@param name: The name of a child element (may contain prefix).
@type name: basestring
@param ns: An optional namespace used to match the child.
@type ns: (I{prefix}, I{name})
@param default: Returned when child ... |
Get a child by (optional) name and/or (optional) namespace.
| def getChild(self, name, ns=None, default=None):
"""
Get a child by (optional) name and/or (optional) namespace.
@param name: The name of a child element (may contain prefix).
@type name: basestring
@param ns: An optional namespace used to match the child.
@type ns: (I{pr... | [
"def",
"getChild",
"(",
"self",
",",
"name",
",",
"ns",
"=",
"None",
",",
"default",
"=",
"None",
")",
":",
"if",
"ns",
"is",
"None",
":",
"prefix",
",",
"name",
"=",
"splitPrefix",
"(",
"name",
")",
"if",
"prefix",
"is",
"None",
":",
"ns",
"=",
... | [
413,
4
] | [
434,
22
] | python | en | ['en', 'error', 'th'] | False |
Element.childAtPath | (self, path) |
Get a child at I{path} where I{path} is a (/) separated
list of element names that are expected to be children.
@param path: A (/) separated list of element names.
@type path: basestring
@return: The leaf node at the end of I{path}
@rtype: L{Element}
|
Get a child at I{path} where I{path} is a (/) separated
list of element names that are expected to be children.
| def childAtPath(self, path):
"""
Get a child at I{path} where I{path} is a (/) separated
list of element names that are expected to be children.
@param path: A (/) separated list of element names.
@type path: basestring
@return: The leaf node at the end of I{path}
... | [
"def",
"childAtPath",
"(",
"self",
",",
"path",
")",
":",
"result",
"=",
"None",
"node",
"=",
"self",
"for",
"name",
"in",
"[",
"p",
"for",
"p",
"in",
"path",
".",
"split",
"(",
"'/'",
")",
"if",
"len",
"(",
"p",
")",
">",
"0",
"]",
":",
"ns"... | [
436,
4
] | [
457,
21
] | python | en | ['en', 'error', 'th'] | False |
Element.childrenAtPath | (self, path) |
Get a list of children at I{path} where I{path} is a (/) separated
list of element names that are expected to be children.
@param path: A (/) separated list of element names.
@type path: basestring
@return: The collection leaf nodes at the end of I{path}
@rtype: [L{Eleme... |
Get a list of children at I{path} where I{path} is a (/) separated
list of element names that are expected to be children.
| def childrenAtPath(self, path):
"""
Get a list of children at I{path} where I{path} is a (/) separated
list of element names that are expected to be children.
@param path: A (/) separated list of element names.
@type path: basestring
@return: The collection leaf nodes at ... | [
"def",
"childrenAtPath",
"(",
"self",
",",
"path",
")",
":",
"parts",
"=",
"[",
"p",
"for",
"p",
"in",
"path",
".",
"split",
"(",
"'/'",
")",
"if",
"len",
"(",
"p",
")",
">",
"0",
"]",
"if",
"len",
"(",
"parts",
")",
"==",
"1",
":",
"result",... | [
459,
4
] | [
473,
21
] | python | en | ['en', 'error', 'th'] | False |
Element.getChildren | (self, name=None, ns=None) |
Get a list of children by (optional) name and/or (optional) namespace.
@param name: The name of a child element (may contain prefix).
@type name: basestring
@param ns: An optional namespace used to match the child.
@type ns: (I{prefix}, I{name})
@return: The list of matc... |
Get a list of children by (optional) name and/or (optional) namespace.
| def getChildren(self, name=None, ns=None):
"""
Get a list of children by (optional) name and/or (optional) namespace.
@param name: The name of a child element (may contain prefix).
@type name: basestring
@param ns: An optional namespace used to match the child.
@type ns: ... | [
"def",
"getChildren",
"(",
"self",
",",
"name",
"=",
"None",
",",
"ns",
"=",
"None",
")",
":",
"if",
"ns",
"is",
"None",
":",
"if",
"name",
"is",
"None",
":",
"return",
"self",
".",
"children",
"prefix",
",",
"name",
"=",
"splitPrefix",
"(",
"name"... | [
475,
4
] | [
493,
62
] | python | en | ['en', 'error', 'th'] | False |
Element.detachChildren | (self) |
Detach and return this element's children.
@return: The element's children (detached).
@rtype: [L{Element},...]
|
Detach and return this element's children.
| def detachChildren(self):
"""
Detach and return this element's children.
@return: The element's children (detached).
@rtype: [L{Element},...]
"""
detached = self.children
self.children = []
for child in detached:
child.parent = None
ret... | [
"def",
"detachChildren",
"(",
"self",
")",
":",
"detached",
"=",
"self",
".",
"children",
"self",
".",
"children",
"=",
"[",
"]",
"for",
"child",
"in",
"detached",
":",
"child",
".",
"parent",
"=",
"None",
"return",
"detached"
] | [
495,
4
] | [
505,
23
] | python | en | ['en', 'error', 'th'] | False |
Element.resolvePrefix | (self, prefix, default=Namespace.default) |
Resolve the specified prefix to a namespace. The I{nsprefixes} is
searched. If not found, it walks up the tree until either resolved or
the top of the tree is reached. Searching up the tree provides for
inherited mappings.
@param prefix: A namespace prefix to resolve.
... |
Resolve the specified prefix to a namespace. The I{nsprefixes} is
searched. If not found, it walks up the tree until either resolved or
the top of the tree is reached. Searching up the tree provides for
inherited mappings.
| def resolvePrefix(self, prefix, default=Namespace.default):
"""
Resolve the specified prefix to a namespace. The I{nsprefixes} is
searched. If not found, it walks up the tree until either resolved or
the top of the tree is reached. Searching up the tree provides for
inherited ... | [
"def",
"resolvePrefix",
"(",
"self",
",",
"prefix",
",",
"default",
"=",
"Namespace",
".",
"default",
")",
":",
"n",
"=",
"self",
"while",
"n",
"is",
"not",
"None",
":",
"if",
"prefix",
"in",
"n",
".",
"nsprefixes",
":",
"return",
"(",
"prefix",
",",... | [
507,
4
] | [
528,
22
] | python | en | ['en', 'error', 'th'] | False |
Element.addPrefix | (self, p, u) |
Add or update a prefix mapping.
@param p: A prefix.
@type p: basestring
@param u: A namespace URI.
@type u: basestring
@return: self
@rtype: L{Element}
|
Add or update a prefix mapping.
| def addPrefix(self, p, u):
"""
Add or update a prefix mapping.
@param p: A prefix.
@type p: basestring
@param u: A namespace URI.
@type u: basestring
@return: self
@rtype: L{Element}
"""
self.nsprefixes[p] = u
return self | [
"def",
"addPrefix",
"(",
"self",
",",
"p",
",",
"u",
")",
":",
"self",
".",
"nsprefixes",
"[",
"p",
"]",
"=",
"u",
"return",
"self"
] | [
530,
4
] | [
541,
19
] | python | en | ['en', 'error', 'th'] | False |
Element.updatePrefix | (self, p, u) |
Update (redefine) a prefix mapping for the branch.
@param p: A prefix.
@type p: basestring
@param u: A namespace URI.
@type u: basestring
@return: self
@rtype: L{Element}
@note: This method traverses down the entire branch!
|
Update (redefine) a prefix mapping for the branch.
| def updatePrefix(self, p, u):
"""
Update (redefine) a prefix mapping for the branch.
@param p: A prefix.
@type p: basestring
@param u: A namespace URI.
@type u: basestring
@return: self
@rtype: L{Element}
@note: This method traverses down the enti... | [
"def",
"updatePrefix",
"(",
"self",
",",
"p",
",",
"u",
")",
":",
"if",
"p",
"in",
"self",
".",
"nsprefixes",
":",
"self",
".",
"nsprefixes",
"[",
"p",
"]",
"=",
"u",
"for",
"c",
"in",
"self",
".",
"children",
":",
"c",
".",
"updatePrefix",
"(",
... | [
543,
4
] | [
558,
19
] | python | en | ['en', 'error', 'th'] | False |
Element.clearPrefix | (self, prefix) |
Clear the specified prefix from the prefix mappings.
@param prefix: A prefix to clear.
@type prefix: basestring
@return: self
@rtype: L{Element}
|
Clear the specified prefix from the prefix mappings.
| def clearPrefix(self, prefix):
"""
Clear the specified prefix from the prefix mappings.
@param prefix: A prefix to clear.
@type prefix: basestring
@return: self
@rtype: L{Element}
"""
if prefix in self.nsprefixes:
del self.nsprefixes[prefix]
... | [
"def",
"clearPrefix",
"(",
"self",
",",
"prefix",
")",
":",
"if",
"prefix",
"in",
"self",
".",
"nsprefixes",
":",
"del",
"self",
".",
"nsprefixes",
"[",
"prefix",
"]",
"return",
"self"
] | [
560,
4
] | [
570,
19
] | python | en | ['en', 'error', 'th'] | False |
Element.findPrefix | (self, uri, default=None) |
Find the first prefix that has been mapped to a namespace URI.
The local mapping is searched, then it walks up the tree until
it reaches the top or finds a match.
@param uri: A namespace URI.
@type uri: basestring
@param default: A default prefix when not found.
... |
Find the first prefix that has been mapped to a namespace URI.
The local mapping is searched, then it walks up the tree until
it reaches the top or finds a match.
| def findPrefix(self, uri, default=None):
"""
Find the first prefix that has been mapped to a namespace URI.
The local mapping is searched, then it walks up the tree until
it reaches the top or finds a match.
@param uri: A namespace URI.
@type uri: basestring
@para... | [
"def",
"findPrefix",
"(",
"self",
",",
"uri",
",",
"default",
"=",
"None",
")",
":",
"for",
"item",
"in",
"self",
".",
"nsprefixes",
".",
"items",
"(",
")",
":",
"if",
"item",
"[",
"1",
"]",
"==",
"uri",
":",
"prefix",
"=",
"item",
"[",
"0",
"]... | [
572,
4
] | [
595,
26
] | python | en | ['en', 'error', 'th'] | False |
Element.findPrefixes | (self, uri, match='eq') |
Find all prefixes that has been mapped to a namespace URI.
The local mapping is searched, then it walks up the tree until
it reaches the top collecting all matches.
@param uri: A namespace URI.
@type uri: basestring
@param match: A matching function L{Element.matcher}.
... |
Find all prefixes that has been mapped to a namespace URI.
The local mapping is searched, then it walks up the tree until
it reaches the top collecting all matches.
| def findPrefixes(self, uri, match='eq'):
"""
Find all prefixes that has been mapped to a namespace URI.
The local mapping is searched, then it walks up the tree until
it reaches the top collecting all matches.
@param uri: A namespace URI.
@type uri: basestring
@pa... | [
"def",
"findPrefixes",
"(",
"self",
",",
"uri",
",",
"match",
"=",
"'eq'",
")",
":",
"result",
"=",
"[",
"]",
"for",
"item",
"in",
"self",
".",
"nsprefixes",
".",
"items",
"(",
")",
":",
"if",
"self",
".",
"matcher",
"[",
"match",
"]",
"(",
"item... | [
597,
4
] | [
620,
21
] | python | en | ['en', 'error', 'th'] | False |
Element.promotePrefixes | (self) |
Push prefix declarations up the tree as far as possible. Prefix
mapping are pushed to its parent unless the parent has the
prefix mapped to another URI or the parent has the prefix.
This is propagated up the tree until the top is reached.
@return: self
@rtype: L{Element... |
Push prefix declarations up the tree as far as possible. Prefix
mapping are pushed to its parent unless the parent has the
prefix mapped to another URI or the parent has the prefix.
This is propagated up the tree until the top is reached.
| def promotePrefixes(self):
"""
Push prefix declarations up the tree as far as possible. Prefix
mapping are pushed to its parent unless the parent has the
prefix mapped to another URI or the parent has the prefix.
This is propagated up the tree until the top is reached.
@... | [
"def",
"promotePrefixes",
"(",
"self",
")",
":",
"for",
"c",
"in",
"self",
".",
"children",
":",
"c",
".",
"promotePrefixes",
"(",
")",
"if",
"self",
".",
"parent",
"is",
"None",
":",
"return",
"for",
"p",
",",
"u",
"in",
"self",
".",
"nsprefixes",
... | [
622,
4
] | [
644,
19
] | python | en | ['en', 'error', 'th'] | False |
Element.refitPrefixes | (self) |
Refit namespace qualification by replacing prefixes
with explicit namespaces. Also purges prefix mapping table.
@return: self
@rtype: L{Element}
|
Refit namespace qualification by replacing prefixes
with explicit namespaces. Also purges prefix mapping table.
| def refitPrefixes(self):
"""
Refit namespace qualification by replacing prefixes
with explicit namespaces. Also purges prefix mapping table.
@return: self
@rtype: L{Element}
"""
for c in self.children:
c.refitPrefixes()
if self.prefix is not No... | [
"def",
"refitPrefixes",
"(",
"self",
")",
":",
"for",
"c",
"in",
"self",
".",
"children",
":",
"c",
".",
"refitPrefixes",
"(",
")",
"if",
"self",
".",
"prefix",
"is",
"not",
"None",
":",
"ns",
"=",
"self",
".",
"resolvePrefix",
"(",
"self",
".",
"p... | [
646,
4
] | [
661,
19
] | python | en | ['en', 'error', 'th'] | False |
Element.normalizePrefixes | (self) |
Normalize the namespace prefixes.
This generates unique prefixes for all namespaces. Then retrofits all
prefixes and prefix mappings. Further, it will retrofix attribute values
that have values containing (:).
@return: self
@rtype: L{Element}
|
Normalize the namespace prefixes.
This generates unique prefixes for all namespaces. Then retrofits all
prefixes and prefix mappings. Further, it will retrofix attribute values
that have values containing (:).
| def normalizePrefixes(self):
"""
Normalize the namespace prefixes.
This generates unique prefixes for all namespaces. Then retrofits all
prefixes and prefix mappings. Further, it will retrofix attribute values
that have values containing (:).
@return: self
@rtyp... | [
"def",
"normalizePrefixes",
"(",
"self",
")",
":",
"PrefixNormalizer",
".",
"apply",
"(",
"self",
")",
"return",
"self"
] | [
663,
4
] | [
673,
19
] | python | en | ['en', 'error', 'th'] | False |
Element.isempty | (self, content=True) |
Get whether the element has no children.
@param content: Test content (children & text) only.
@type content: boolean
@return: True when element has not children.
@rtype: boolean
|
Get whether the element has no children.
| def isempty(self, content=True):
"""
Get whether the element has no children.
@param content: Test content (children & text) only.
@type content: boolean
@return: True when element has not children.
@rtype: boolean
"""
noattrs = not len(self.attributes)
... | [
"def",
"isempty",
"(",
"self",
",",
"content",
"=",
"True",
")",
":",
"noattrs",
"=",
"not",
"len",
"(",
"self",
".",
"attributes",
")",
"nochildren",
"=",
"not",
"len",
"(",
"self",
".",
"children",
")",
"notext",
"=",
"(",
"self",
".",
"text",
"i... | [
675,
4
] | [
690,
44
] | python | en | ['en', 'error', 'th'] | False |
Element.isnil | (self) |
Get whether the element is I{nil} as defined by having
an attribute in the I{xsi:nil="true"}
@return: True if I{nil}, else False
@rtype: boolean
|
Get whether the element is I{nil} as defined by having
an attribute in the I{xsi:nil="true"}
| def isnil(self):
"""
Get whether the element is I{nil} as defined by having
an attribute in the I{xsi:nil="true"}
@return: True if I{nil}, else False
@rtype: boolean
"""
nilattr = self.getAttribute('nil', ns=Namespace.xsins)
if nilattr is None:
... | [
"def",
"isnil",
"(",
"self",
")",
":",
"nilattr",
"=",
"self",
".",
"getAttribute",
"(",
"'nil'",
",",
"ns",
"=",
"Namespace",
".",
"xsins",
")",
"if",
"nilattr",
"is",
"None",
":",
"return",
"False",
"else",
":",
"return",
"(",
"nilattr",
".",
"getV... | [
693,
4
] | [
704,
59
] | python | en | ['en', 'error', 'th'] | False |
Element.setnil | (self, flag=True) |
Set this node to I{nil} as defined by having an
attribute I{xsi:nil}=I{flag}.
@param flag: A flag inidcating how I{xsi:nil} will be set.
@type flag: boolean
@return: self
@rtype: L{Element}
|
Set this node to I{nil} as defined by having an
attribute I{xsi:nil}=I{flag}.
| def setnil(self, flag=True):
"""
Set this node to I{nil} as defined by having an
attribute I{xsi:nil}=I{flag}.
@param flag: A flag inidcating how I{xsi:nil} will be set.
@type flag: boolean
@return: self
@rtype: L{Element}
"""
p, u = Namespace.xsin... | [
"def",
"setnil",
"(",
"self",
",",
"flag",
"=",
"True",
")",
":",
"p",
",",
"u",
"=",
"Namespace",
".",
"xsins",
"name",
"=",
"':'",
".",
"join",
"(",
"(",
"p",
",",
"'nil'",
")",
")",
"self",
".",
"set",
"(",
"name",
",",
"str",
"(",
"flag",... | [
706,
4
] | [
721,
19
] | python | en | ['en', 'error', 'th'] | False |
Element.applyns | (self, ns) |
Apply the namespace to this node. If the prefix is I{None} then
this element's explicit namespace I{expns} is set to the
URI defined by I{ns}. Otherwise, the I{ns} is simply mapped.
@param ns: A namespace.
@type ns: (I{prefix},I{URI})
|
Apply the namespace to this node. If the prefix is I{None} then
this element's explicit namespace I{expns} is set to the
URI defined by I{ns}. Otherwise, the I{ns} is simply mapped.
| def applyns(self, ns):
"""
Apply the namespace to this node. If the prefix is I{None} then
this element's explicit namespace I{expns} is set to the
URI defined by I{ns}. Otherwise, the I{ns} is simply mapped.
@param ns: A namespace.
@type ns: (I{prefix},I{URI})
... | [
"def",
"applyns",
"(",
"self",
",",
"ns",
")",
":",
"if",
"ns",
"is",
"None",
":",
"return",
"if",
"not",
"isinstance",
"(",
"ns",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"raise",
"Exception",
"(",
"'namespace must be tuple'",
")",
"if",
"ns",... | [
723,
4
] | [
739,
42
] | python | en | ['en', 'error', 'th'] | False |
Element.str | (self, indent=0) |
Get a string representation of this XML fragment.
@param indent: The indent to be used in formatting the output.
@type indent: int
@return: A I{pretty} string.
@rtype: basestring
|
Get a string representation of this XML fragment.
| def str(self, indent=0):
"""
Get a string representation of this XML fragment.
@param indent: The indent to be used in formatting the output.
@type indent: int
@return: A I{pretty} string.
@rtype: basestring
"""
tab = '%*s'%(indent*3,'')
result = [... | [
"def",
"str",
"(",
"self",
",",
"indent",
"=",
"0",
")",
":",
"tab",
"=",
"'%*s'",
"%",
"(",
"indent",
"*",
"3",
",",
"''",
")",
"result",
"=",
"[",
"]",
"result",
".",
"append",
"(",
"'%s<%s'",
"%",
"(",
"tab",
",",
"self",
".",
"qname",
"("... | [
741,
4
] | [
768,
21
] | python | en | ['en', 'error', 'th'] | False |
Element.plain | (self) |
Get a string representation of this XML fragment.
@return: A I{plain} string.
@rtype: basestring
|
Get a string representation of this XML fragment.
| def plain(self):
"""
Get a string representation of this XML fragment.
@return: A I{plain} string.
@rtype: basestring
"""
result = []
result.append('<%s' % self.qname())
result.append(self.nsdeclarations())
for a in [unicode(a) for a in self.attrib... | [
"def",
"plain",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"result",
".",
"append",
"(",
"'<%s'",
"%",
"self",
".",
"qname",
"(",
")",
")",
"result",
".",
"append",
"(",
"self",
".",
"nsdeclarations",
"(",
")",
")",
"for",
"a",
"in",
"[",
... | [
770,
4
] | [
791,
21
] | python | en | ['en', 'error', 'th'] | False |
Element.nsdeclarations | (self) |
Get a string representation for all namespace declarations
as xmlns="" and xmlns:p="".
@return: A separated list of declarations.
@rtype: basestring
|
Get a string representation for all namespace declarations
as xmlns="" and xmlns:p="".
| def nsdeclarations(self):
"""
Get a string representation for all namespace declarations
as xmlns="" and xmlns:p="".
@return: A separated list of declarations.
@rtype: basestring
"""
s = []
myns = (None, self.expns)
if self.parent is None:
... | [
"def",
"nsdeclarations",
"(",
"self",
")",
":",
"s",
"=",
"[",
"]",
"myns",
"=",
"(",
"None",
",",
"self",
".",
"expns",
")",
"if",
"self",
".",
"parent",
"is",
"None",
":",
"pns",
"=",
"Namespace",
".",
"default",
"else",
":",
"pns",
"=",
"(",
... | [
793,
4
] | [
817,
25
] | python | en | ['en', 'error', 'th'] | False |
Element.match | (self, name=None, ns=None) |
Match by (optional) name and/or (optional) namespace.
@param name: The optional element tag name.
@type name: str
@param ns: An optional namespace.
@type ns: (I{prefix}, I{name})
@return: True if matched.
@rtype: boolean
|
Match by (optional) name and/or (optional) namespace.
| def match(self, name=None, ns=None):
"""
Match by (optional) name and/or (optional) namespace.
@param name: The optional element tag name.
@type name: str
@param ns: An optional namespace.
@type ns: (I{prefix}, I{name})
@return: True if matched.
@rtype: bo... | [
"def",
"match",
"(",
"self",
",",
"name",
"=",
"None",
",",
"ns",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"byname",
"=",
"True",
"else",
":",
"byname",
"=",
"(",
"self",
".",
"name",
"==",
"name",
")",
"if",
"ns",
"is",
"None",
... | [
819,
4
] | [
837,
34
] | python | en | ['en', 'error', 'th'] | False |
Element.branch | (self) |
Get a flattened representation of the branch.
@return: A flat list of nodes.
@rtype: [L{Element},..]
|
Get a flattened representation of the branch.
| def branch(self):
"""
Get a flattened representation of the branch.
@return: A flat list of nodes.
@rtype: [L{Element},..]
"""
branch = [self]
for c in self.children:
branch += c.branch()
return branch | [
"def",
"branch",
"(",
"self",
")",
":",
"branch",
"=",
"[",
"self",
"]",
"for",
"c",
"in",
"self",
".",
"children",
":",
"branch",
"+=",
"c",
".",
"branch",
"(",
")",
"return",
"branch"
] | [
839,
4
] | [
848,
21
] | python | en | ['en', 'error', 'th'] | False |
Element.ancestors | (self) |
Get a list of ancestors.
@return: A list of ancestors.
@rtype: [L{Element},..]
|
Get a list of ancestors.
| def ancestors(self):
"""
Get a list of ancestors.
@return: A list of ancestors.
@rtype: [L{Element},..]
"""
ancestors = []
p = self.parent
while p is not None:
ancestors.append(p)
p = p.parent
return ancestors | [
"def",
"ancestors",
"(",
"self",
")",
":",
"ancestors",
"=",
"[",
"]",
"p",
"=",
"self",
".",
"parent",
"while",
"p",
"is",
"not",
"None",
":",
"ancestors",
".",
"append",
"(",
"p",
")",
"p",
"=",
"p",
".",
"parent",
"return",
"ancestors"
] | [
850,
4
] | [
861,
24
] | python | en | ['en', 'error', 'th'] | False |
Element.walk | (self, visitor) |
Walk the branch and call the visitor function
on each node.
@param visitor: A function.
@return: self
@rtype: L{Element}
|
Walk the branch and call the visitor function
on each node.
| def walk(self, visitor):
"""
Walk the branch and call the visitor function
on each node.
@param visitor: A function.
@return: self
@rtype: L{Element}
"""
visitor(self)
for c in self.children:
c.walk(visitor)
return self | [
"def",
"walk",
"(",
"self",
",",
"visitor",
")",
":",
"visitor",
"(",
"self",
")",
"for",
"c",
"in",
"self",
".",
"children",
":",
"c",
".",
"walk",
"(",
"visitor",
")",
"return",
"self"
] | [
863,
4
] | [
874,
19
] | python | en | ['en', 'error', 'th'] | False |
Element.prune | (self) |
Prune the branch of empty nodes.
|
Prune the branch of empty nodes.
| def prune(self):
"""
Prune the branch of empty nodes.
"""
pruned = []
for c in self.children:
c.prune()
if c.isempty(False):
pruned.append(c)
for p in pruned:
self.children.remove(p) | [
"def",
"prune",
"(",
"self",
")",
":",
"pruned",
"=",
"[",
"]",
"for",
"c",
"in",
"self",
".",
"children",
":",
"c",
".",
"prune",
"(",
")",
"if",
"c",
".",
"isempty",
"(",
"False",
")",
":",
"pruned",
".",
"append",
"(",
"c",
")",
"for",
"p"... | [
876,
4
] | [
886,
35
] | python | en | ['en', 'error', 'th'] | False |
NodeIterator.__init__ | (self, parent) |
@param parent: An element to iterate.
@type parent: L{Element}
| def __init__(self, parent):
"""
@param parent: An element to iterate.
@type parent: L{Element}
"""
self.pos = 0
self.children = parent.children | [
"def",
"__init__",
"(",
"self",
",",
"parent",
")",
":",
"self",
".",
"pos",
"=",
"0",
"self",
".",
"children",
"=",
"parent",
".",
"children"
] | [
962,
4
] | [
968,
39
] | python | en | ['en', 'error', 'th'] | False | |
NodeIterator.next | (self) |
Get the next child.
@return: The next child.
@rtype: L{Element}
@raise StopIterator: At the end.
|
Get the next child.
| def next(self):
"""
Get the next child.
@return: The next child.
@rtype: L{Element}
@raise StopIterator: At the end.
"""
try:
child = self.children[self.pos]
self.pos += 1
return child
except:
raise StopItera... | [
"def",
"next",
"(",
"self",
")",
":",
"try",
":",
"child",
"=",
"self",
".",
"children",
"[",
"self",
".",
"pos",
"]",
"self",
".",
"pos",
"+=",
"1",
"return",
"child",
"except",
":",
"raise",
"StopIteration",
"(",
")"
] | [
970,
4
] | [
982,
33
] | python | en | ['en', 'error', 'th'] | False |
PrefixNormalizer.apply | (cls, node) |
Normalize the specified node.
@param node: A node to normalize.
@type node: L{Element}
@return: The normalized node.
@rtype: L{Element}
|
Normalize the specified node.
| def apply(cls, node):
"""
Normalize the specified node.
@param node: A node to normalize.
@type node: L{Element}
@return: The normalized node.
@rtype: L{Element}
"""
pn = PrefixNormalizer(node)
return pn.refit() | [
"def",
"apply",
"(",
"cls",
",",
"node",
")",
":",
"pn",
"=",
"PrefixNormalizer",
"(",
"node",
")",
"return",
"pn",
".",
"refit",
"(",
")"
] | [
999,
4
] | [
1008,
25
] | python | en | ['en', 'error', 'th'] | False |
PrefixNormalizer.__init__ | (self, node) |
@param node: A node to normalize.
@type node: L{Element}
| def __init__(self, node):
"""
@param node: A node to normalize.
@type node: L{Element}
"""
self.node = node
self.branch = node.branch()
self.namespaces = self.getNamespaces()
self.prefixes = self.genPrefixes() | [
"def",
"__init__",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"node",
"=",
"node",
"self",
".",
"branch",
"=",
"node",
".",
"branch",
"(",
")",
"self",
".",
"namespaces",
"=",
"self",
".",
"getNamespaces",
"(",
")",
"self",
".",
"prefixes",
"... | [
1010,
4
] | [
1018,
42
] | python | en | ['en', 'error', 'th'] | False | |
PrefixNormalizer.getNamespaces | (self) |
Get the I{unique} set of namespaces referenced in the branch.
@return: A set of namespaces.
@rtype: set
|
Get the I{unique} set of namespaces referenced in the branch.
| def getNamespaces(self):
"""
Get the I{unique} set of namespaces referenced in the branch.
@return: A set of namespaces.
@rtype: set
"""
s = set()
for n in self.branch + self.node.ancestors():
if self.permit(n.expns):
s.add(n.expns)
... | [
"def",
"getNamespaces",
"(",
"self",
")",
":",
"s",
"=",
"set",
"(",
")",
"for",
"n",
"in",
"self",
".",
"branch",
"+",
"self",
".",
"node",
".",
"ancestors",
"(",
")",
":",
"if",
"self",
".",
"permit",
"(",
"n",
".",
"expns",
")",
":",
"s",
... | [
1020,
4
] | [
1031,
16
] | python | en | ['en', 'error', 'th'] | False |
PrefixNormalizer.pset | (self, n) |
Convert the nodes nsprefixes into a set.
@param n: A node.
@type n: L{Element}
@return: A set of namespaces.
@rtype: set
|
Convert the nodes nsprefixes into a set.
| def pset(self, n):
"""
Convert the nodes nsprefixes into a set.
@param n: A node.
@type n: L{Element}
@return: A set of namespaces.
@rtype: set
"""
s = set()
for ns in n.nsprefixes.items():
if self.permit(ns):
s.add(ns[1... | [
"def",
"pset",
"(",
"self",
",",
"n",
")",
":",
"s",
"=",
"set",
"(",
")",
"for",
"ns",
"in",
"n",
".",
"nsprefixes",
".",
"items",
"(",
")",
":",
"if",
"self",
".",
"permit",
"(",
"ns",
")",
":",
"s",
".",
"add",
"(",
"ns",
"[",
"1",
"]"... | [
1033,
4
] | [
1045,
16
] | python | en | ['en', 'error', 'th'] | False |
PrefixNormalizer.genPrefixes | (self) |
Generate a I{reverse} mapping of unique prefixes for all namespaces.
@return: A referse dict of prefixes.
@rtype: {u, p}
|
Generate a I{reverse} mapping of unique prefixes for all namespaces.
| def genPrefixes(self):
"""
Generate a I{reverse} mapping of unique prefixes for all namespaces.
@return: A referse dict of prefixes.
@rtype: {u, p}
"""
prefixes = {}
n = 0
for u in self.namespaces:
p = 'ns%d' % n
prefixes[u] = p
... | [
"def",
"genPrefixes",
"(",
"self",
")",
":",
"prefixes",
"=",
"{",
"}",
"n",
"=",
"0",
"for",
"u",
"in",
"self",
".",
"namespaces",
":",
"p",
"=",
"'ns%d'",
"%",
"n",
"prefixes",
"[",
"u",
"]",
"=",
"p",
"n",
"+=",
"1",
"return",
"prefixes"
] | [
1047,
4
] | [
1059,
23
] | python | en | ['en', 'error', 'th'] | False |
PrefixNormalizer.refit | (self) |
Refit (normalize) the prefixes in the node.
|
Refit (normalize) the prefixes in the node.
| def refit(self):
"""
Refit (normalize) the prefixes in the node.
"""
self.refitNodes()
self.refitMappings() | [
"def",
"refit",
"(",
"self",
")",
":",
"self",
".",
"refitNodes",
"(",
")",
"self",
".",
"refitMappings",
"(",
")"
] | [
1061,
4
] | [
1066,
28
] | python | en | ['en', 'error', 'th'] | False |
PrefixNormalizer.refitNodes | (self) |
Refit (normalize) all of the nodes in the branch.
|
Refit (normalize) all of the nodes in the branch.
| def refitNodes(self):
"""
Refit (normalize) all of the nodes in the branch.
"""
for n in self.branch:
if n.prefix is not None:
ns = n.namespace()
if self.permit(ns):
n.prefix = self.prefixes[ns[1]]
self.refitAttr... | [
"def",
"refitNodes",
"(",
"self",
")",
":",
"for",
"n",
"in",
"self",
".",
"branch",
":",
"if",
"n",
".",
"prefix",
"is",
"not",
"None",
":",
"ns",
"=",
"n",
".",
"namespace",
"(",
")",
"if",
"self",
".",
"permit",
"(",
"ns",
")",
":",
"n",
"... | [
1068,
4
] | [
1077,
30
] | python | en | ['en', 'error', 'th'] | False |
PrefixNormalizer.refitAttrs | (self, n) |
Refit (normalize) all of the attributes in the node.
@param n: A node.
@type n: L{Element}
|
Refit (normalize) all of the attributes in the node.
| def refitAttrs(self, n):
"""
Refit (normalize) all of the attributes in the node.
@param n: A node.
@type n: L{Element}
"""
for a in n.attributes:
self.refitAddr(a) | [
"def",
"refitAttrs",
"(",
"self",
",",
"n",
")",
":",
"for",
"a",
"in",
"n",
".",
"attributes",
":",
"self",
".",
"refitAddr",
"(",
"a",
")"
] | [
1079,
4
] | [
1086,
29
] | python | en | ['en', 'error', 'th'] | False |
PrefixNormalizer.refitAddr | (self, a) |
Refit (normalize) the attribute.
@param a: An attribute.
@type a: L{Attribute}
|
Refit (normalize) the attribute.
| def refitAddr(self, a):
"""
Refit (normalize) the attribute.
@param a: An attribute.
@type a: L{Attribute}
"""
if a.prefix is not None:
ns = a.namespace()
if self.permit(ns):
a.prefix = self.prefixes[ns[1]]
self.refitValue(a... | [
"def",
"refitAddr",
"(",
"self",
",",
"a",
")",
":",
"if",
"a",
".",
"prefix",
"is",
"not",
"None",
":",
"ns",
"=",
"a",
".",
"namespace",
"(",
")",
"if",
"self",
".",
"permit",
"(",
"ns",
")",
":",
"a",
".",
"prefix",
"=",
"self",
".",
"pref... | [
1088,
4
] | [
1098,
26
] | python | en | ['en', 'error', 'th'] | False |
PrefixNormalizer.refitValue | (self, a) |
Refit (normalize) the attribute's value.
@param a: An attribute.
@type a: L{Attribute}
|
Refit (normalize) the attribute's value.
| def refitValue(self, a):
"""
Refit (normalize) the attribute's value.
@param a: An attribute.
@type a: L{Attribute}
"""
p,name = splitPrefix(a.getValue())
if p is None: return
ns = a.resolvePrefix(p)
if self.permit(ns):
u = ns[1]
... | [
"def",
"refitValue",
"(",
"self",
",",
"a",
")",
":",
"p",
",",
"name",
"=",
"splitPrefix",
"(",
"a",
".",
"getValue",
"(",
")",
")",
"if",
"p",
"is",
"None",
":",
"return",
"ns",
"=",
"a",
".",
"resolvePrefix",
"(",
"p",
")",
"if",
"self",
"."... | [
1100,
4
] | [
1112,
43
] | python | en | ['en', 'error', 'th'] | False |
PrefixNormalizer.refitMappings | (self) |
Refit (normalize) all of the nsprefix mappings.
|
Refit (normalize) all of the nsprefix mappings.
| def refitMappings(self):
"""
Refit (normalize) all of the nsprefix mappings.
"""
for n in self.branch:
n.nsprefixes = {}
n = self.node
for u, p in self.prefixes.items():
n.addPrefix(p, u) | [
"def",
"refitMappings",
"(",
"self",
")",
":",
"for",
"n",
"in",
"self",
".",
"branch",
":",
"n",
".",
"nsprefixes",
"=",
"{",
"}",
"n",
"=",
"self",
".",
"node",
"for",
"u",
",",
"p",
"in",
"self",
".",
"prefixes",
".",
"items",
"(",
")",
":",... | [
1114,
4
] | [
1122,
29
] | python | en | ['en', 'error', 'th'] | False |
PrefixNormalizer.permit | (self, ns) |
Get whether the I{ns} is to be normalized.
@param ns: A namespace.
@type ns: (p,u)
@return: True if to be included.
@rtype: boolean
|
Get whether the I{ns} is to be normalized.
| def permit(self, ns):
"""
Get whether the I{ns} is to be normalized.
@param ns: A namespace.
@type ns: (p,u)
@return: True if to be included.
@rtype: boolean
"""
return not self.skip(ns) | [
"def",
"permit",
"(",
"self",
",",
"ns",
")",
":",
"return",
"not",
"self",
".",
"skip",
"(",
"ns",
")"
] | [
1124,
4
] | [
1132,
32
] | python | en | ['en', 'error', 'th'] | False |
PrefixNormalizer.skip | (self, ns) |
Get whether the I{ns} is to B{not} be normalized.
@param ns: A namespace.
@type ns: (p,u)
@return: True if to be skipped.
@rtype: boolean
|
Get whether the I{ns} is to B{not} be normalized.
| def skip(self, ns):
"""
Get whether the I{ns} is to B{not} be normalized.
@param ns: A namespace.
@type ns: (p,u)
@return: True if to be skipped.
@rtype: boolean
"""
return ns is None or \
( ns == Namespace.default ) or \
( ns == Na... | [
"def",
"skip",
"(",
"self",
",",
"ns",
")",
":",
"return",
"ns",
"is",
"None",
"or",
"(",
"ns",
"==",
"Namespace",
".",
"default",
")",
"or",
"(",
"ns",
"==",
"Namespace",
".",
"xsdns",
")",
"or",
"(",
"ns",
"==",
"Namespace",
".",
"xsins",
")",
... | [
1134,
4
] | [
1146,
37
] | python | en | ['en', 'error', 'th'] | False |
SOCKSConnection._new_conn | (self) |
Establish a new connection via the SOCKS proxy.
|
Establish a new connection via the SOCKS proxy.
| def _new_conn(self):
"""
Establish a new connection via the SOCKS proxy.
"""
extra_kw = {}
if self.source_address:
extra_kw["source_address"] = self.source_address
if self.socket_options:
extra_kw["socket_options"] = self.socket_options
t... | [
"def",
"_new_conn",
"(",
"self",
")",
":",
"extra_kw",
"=",
"{",
"}",
"if",
"self",
".",
"source_address",
":",
"extra_kw",
"[",
"\"source_address\"",
"]",
"=",
"self",
".",
"source_address",
"if",
"self",
".",
"socket_options",
":",
"extra_kw",
"[",
"\"so... | [
77,
4
] | [
133,
19
] | python | en | ['en', 'error', 'th'] | False |
TestImagesBasic.test_image_create_delete | (self) | tests the image creation and deletion functionalities:
* creates a new image from horizon.conf http_image
* verifies the image appears in the images table as active
* deletes the newly created image
* verifies the image does not appear in the table after deletion
| tests the image creation and deletion functionalities: | def test_image_create_delete(self):
"""tests the image creation and deletion functionalities:
* creates a new image from horizon.conf http_image
* verifies the image appears in the images table as active
* deletes the newly created image
* verifies the image does not appear in t... | [
"def",
"test_image_create_delete",
"(",
"self",
")",
":",
"self",
".",
"image_create",
"(",
")",
"self",
".",
"image_delete",
"(",
"self",
".",
"IMAGE_NAME",
")"
] | [
74,
4
] | [
83,
42
] | python | en | ['en', 'en', 'en'] | True |
TestImagesBasic.test_image_create_delete_from_local_file | (self) | tests the image creation and deletion functionalities:
* downloads image from horizon.conf stated in http_image
* creates the image from the downloaded file
* verifies the image appears in the images table as active
* deletes the newly created image
* verifies the image does not... | tests the image creation and deletion functionalities: | def test_image_create_delete_from_local_file(self):
"""tests the image creation and deletion functionalities:
* downloads image from horizon.conf stated in http_image
* creates the image from the downloaded file
* verifies the image appears in the images table as active
* delete... | [
"def",
"test_image_create_delete_from_local_file",
"(",
"self",
")",
":",
"with",
"helpers",
".",
"gen_temporary_file",
"(",
")",
"as",
"file_name",
":",
"self",
".",
"image_create",
"(",
"local_file",
"=",
"file_name",
")",
"self",
".",
"image_delete",
"(",
"se... | [
85,
4
] | [
96,
46
] | python | en | ['en', 'en', 'en'] | True |
TestImagesBasic.test_images_pagination | (self) | This test checks images pagination
Steps:
1) Login to Horizon Dashboard as horizon user
2) Navigate to user settings page
3) Change 'Items Per Page' value to 1
4) Go to Project -> Compute -> Images page
5) Check that only 'Next' link is available, only one image is
... | This test checks images pagination | def test_images_pagination(self):
"""This test checks images pagination
Steps:
1) Login to Horizon Dashboard as horizon user
2) Navigate to user settings page
3) Change 'Items Per Page' value to 1
4) Go to Project -> Compute -> Images page
5) Check that only 'Nex... | [
"def",
"test_images_pagination",
"(",
"self",
")",
":",
"default_image_list",
"=",
"self",
".",
"CONFIG",
".",
"image",
".",
"images_list",
"items_per_page",
"=",
"1",
"first_page_definition",
"=",
"{",
"'Next'",
":",
"True",
",",
"'Prev'",
":",
"False",
",",
... | [
98,
4
] | [
149,
64
] | python | en | ['en', 'en', 'en'] | True |
TestImagesBasic.test_update_image_metadata | (self) | Test update image metadata
* logs in as admin user
* creates image from locally downloaded file
* verifies the image appears in the images table as active
* invokes action 'Update Metadata' for the image
* adds custom filed 'metadata'
* adds value 'image' for the custom ... | Test update image metadata | def test_update_image_metadata(self):
"""Test update image metadata
* logs in as admin user
* creates image from locally downloaded file
* verifies the image appears in the images table as active
* invokes action 'Update Metadata' for the image
* adds custom filed 'metad... | [
"def",
"test_update_image_metadata",
"(",
"self",
")",
":",
"new_metadata",
"=",
"{",
"'metadata1'",
":",
"helpers",
".",
"gen_random_resource_name",
"(",
"\"value\"",
")",
",",
"'metadata2'",
":",
"helpers",
".",
"gen_random_resource_name",
"(",
"\"value\"",
")",
... | [
151,
4
] | [
178,
44
] | python | en | ['en', 'la', 'it'] | False |
TestImagesBasic.test_remove_protected_image | (self) | tests that protected image is not deletable
* logs in as admin user
* creates image from locally downloaded file
* verifies the image appears in the images table as active
* marks 'Protected' checkbox
* verifies that edit action was successful
* verifies that delete acti... | tests that protected image is not deletable | def test_remove_protected_image(self):
"""tests that protected image is not deletable
* logs in as admin user
* creates image from locally downloaded file
* verifies the image appears in the images table as active
* marks 'Protected' checkbox
* verifies that edit action ... | [
"def",
"test_remove_protected_image",
"(",
"self",
")",
":",
"with",
"helpers",
".",
"gen_temporary_file",
"(",
")",
"as",
"file_name",
":",
"images_page",
"=",
"self",
".",
"image_create",
"(",
"local_file",
"=",
"file_name",
")",
"images_page",
".",
"edit_imag... | [
180,
4
] | [
218,
46
] | python | en | ['en', 'en', 'en'] | True |
TestImagesBasic.test_edit_image_description_and_name | (self) | tests that image description is editable
* creates image from locally downloaded file
* verifies the image appears in the images table as active
* toggle edit action and adds some description
* verifies that edit action was successful
* verifies that new description is seen on i... | tests that image description is editable | def test_edit_image_description_and_name(self):
"""tests that image description is editable
* creates image from locally downloaded file
* verifies the image appears in the images table as active
* toggle edit action and adds some description
* verifies that edit action was succ... | [
"def",
"test_edit_image_description_and_name",
"(",
"self",
")",
":",
"new_description_text",
"=",
"helpers",
".",
"gen_random_resource_name",
"(",
"\"description\"",
")",
"new_image_name",
"=",
"helpers",
".",
"gen_random_resource_name",
"(",
"\"image\"",
")",
"with",
... | [
220,
4
] | [
264,
45
] | python | en | ['en', 'fr', 'en'] | True |
TestImagesAdvanced.test_create_volume_from_image | (self) | This test case checks create volume from image functionality:
Steps:
1. Login to Horizon Dashboard as regular user
2. Navigate to Project -> Compute -> Images
3. Create new volume from image
4. Check that volume is created with expected name
5. Check that volume status i... | This test case checks create volume from image functionality: | def test_create_volume_from_image(self):
"""This test case checks create volume from image functionality:
Steps:
1. Login to Horizon Dashboard as regular user
2. Navigate to Project -> Compute -> Images
3. Create new volume from image
4. Check that volume is created with... | [
"def",
"test_create_volume_from_image",
"(",
"self",
")",
":",
"images_page",
"=",
"self",
".",
"images_page",
"source_image",
"=",
"self",
".",
"CONFIG",
".",
"image",
".",
"images_list",
"[",
"0",
"]",
"target_volume",
"=",
"\"created_from_{0}\"",
".",
"format... | [
269,
4
] | [
295,
70
] | python | en | ['en', 'en', 'en'] | True |
TestImagesAdvanced.test_launch_instance_from_image | (self) | This test case checks launch instance from image functionality:
Steps:
1. Login to Horizon Dashboard as regular user
2. Navigate to Project -> Compute -> Images
3. Launch new instance from image
4. Check that instance is create
5. Check that status of newly created insta... | This test case checks launch instance from image functionality: | def test_launch_instance_from_image(self):
"""This test case checks launch instance from image functionality:
Steps:
1. Login to Horizon Dashboard as regular user
2. Navigate to Project -> Compute -> Images
3. Launch new instance from image
4. Check that instance is crea... | [
"def",
"test_launch_instance_from_image",
"(",
"self",
")",
":",
"images_page",
"=",
"self",
".",
"images_page",
"source_image",
"=",
"self",
".",
"CONFIG",
".",
"image",
".",
"images_list",
"[",
"0",
"]",
"target_instance",
"=",
"\"created_from_{0}\"",
".",
"fo... | [
297,
4
] | [
326,
76
] | python | en | ['en', 'en', 'en'] | True |
TestImagesAdmin.test_filter_images | (self) | This test checks filtering of images
Steps:
1) Login to Horizon dashboard as admin user
2) Go to Admin -> Compute -> Images
3) Use filter by Image Name
4) Check that filtered table has one image only (which name is
equal to filter value)
5) Check that no other... | This test checks filtering of images | def test_filter_images(self):
"""This test checks filtering of images
Steps:
1) Login to Horizon dashboard as admin user
2) Go to Admin -> Compute -> Images
3) Use filter by Image Name
4) Check that filtered table has one image only (which name is
equal to fil... | [
"def",
"test_filter_images",
"(",
"self",
")",
":",
"images_list",
"=",
"self",
".",
"CONFIG",
".",
"image",
".",
"images_list",
"images_page",
"=",
"self",
".",
"images_page",
"images_page",
".",
"images_table",
".",
"filter",
"(",
"images_list",
"[",
"0",
... | [
339,
4
] | [
364,
43
] | python | en | ['en', 'en', 'en'] | True |
samefile | (p1, p2) |
Determine if two paths reference the same file.
Augments os.path.samefile to work on Windows and
suppresses errors if the path doesn't exist.
|
Determine if two paths reference the same file. | def samefile(p1, p2):
"""
Determine if two paths reference the same file.
Augments os.path.samefile to work on Windows and
suppresses errors if the path doesn't exist.
"""
both_exist = os.path.exists(p1) and os.path.exists(p2)
use_samefile = hasattr(os.path, 'samefile') and both_exist
i... | [
"def",
"samefile",
"(",
"p1",
",",
"p2",
")",
":",
"both_exist",
"=",
"os",
".",
"path",
".",
"exists",
"(",
"p1",
")",
"and",
"os",
".",
"path",
".",
"exists",
"(",
"p2",
")",
"use_samefile",
"=",
"hasattr",
"(",
"os",
".",
"path",
",",
"'samefi... | [
77,
0
] | [
90,
29
] | python | en | ['en', 'error', 'th'] | False |
get_site_dirs | () |
Return a list of 'site' dirs
|
Return a list of 'site' dirs
| def get_site_dirs():
"""
Return a list of 'site' dirs
"""
sitedirs = []
# start with PYTHONPATH
sitedirs.extend(_pythonpath())
prefixes = [sys.prefix]
if sys.exec_prefix != sys.prefix:
prefixes.append(sys.exec_prefix)
for prefix in prefixes:
if prefix:
... | [
"def",
"get_site_dirs",
"(",
")",
":",
"sitedirs",
"=",
"[",
"]",
"# start with PYTHONPATH",
"sitedirs",
".",
"extend",
"(",
"_pythonpath",
"(",
")",
")",
"prefixes",
"=",
"[",
"sys",
".",
"prefix",
"]",
"if",
"sys",
".",
"exec_prefix",
"!=",
"sys",
".",... | [
1348,
0
] | [
1410,
19
] | python | en | ['en', 'error', 'th'] | False |
expand_paths | (inputs) | Yield sys.path directories that might contain "old-style" packages | Yield sys.path directories that might contain "old-style" packages | def expand_paths(inputs):
"""Yield sys.path directories that might contain "old-style" packages"""
seen = {}
for dirname in inputs:
dirname = normalize_path(dirname)
if dirname in seen:
continue
seen[dirname] = 1
if not os.path.isdir(dirname):
conti... | [
"def",
"expand_paths",
"(",
"inputs",
")",
":",
"seen",
"=",
"{",
"}",
"for",
"dirname",
"in",
"inputs",
":",
"dirname",
"=",
"normalize_path",
"(",
"dirname",
")",
"if",
"dirname",
"in",
"seen",
":",
"continue",
"seen",
"[",
"dirname",
"]",
"=",
"1",
... | [
1413,
0
] | [
1451,
52
] | python | en | ['en', 'en', 'en'] | True |
extract_wininst_cfg | (dist_filename) | Extract configuration data from a bdist_wininst .exe
Returns a configparser.RawConfigParser, or None
| Extract configuration data from a bdist_wininst .exe | def extract_wininst_cfg(dist_filename):
"""Extract configuration data from a bdist_wininst .exe
Returns a configparser.RawConfigParser, or None
"""
f = open(dist_filename, 'rb')
try:
endrec = zipfile._EndRecData(f)
if endrec is None:
return None
prepended = (end... | [
"def",
"extract_wininst_cfg",
"(",
"dist_filename",
")",
":",
"f",
"=",
"open",
"(",
"dist_filename",
",",
"'rb'",
")",
"try",
":",
"endrec",
"=",
"zipfile",
".",
"_EndRecData",
"(",
"f",
")",
"if",
"endrec",
"is",
"None",
":",
"return",
"None",
"prepend... | [
1454,
0
] | [
1492,
17
] | python | en | ['en', 'en', 'en'] | True |
get_exe_prefixes | (exe_filename) | Get exe->egg path translations for a given .exe file | Get exe->egg path translations for a given .exe file | def get_exe_prefixes(exe_filename):
"""Get exe->egg path translations for a given .exe file"""
prefixes = [
('PURELIB/', ''),
('PLATLIB/pywin32_system32', ''),
('PLATLIB/', ''),
('SCRIPTS/', 'EGG-INFO/scripts/'),
('DATA/lib/site-packages', ''),
]
z = zipfile.ZipF... | [
"def",
"get_exe_prefixes",
"(",
"exe_filename",
")",
":",
"prefixes",
"=",
"[",
"(",
"'PURELIB/'",
",",
"''",
")",
",",
"(",
"'PLATLIB/pywin32_system32'",
",",
"''",
")",
",",
"(",
"'PLATLIB/'",
",",
"''",
")",
",",
"(",
"'SCRIPTS/'",
",",
"'EGG-INFO/scrip... | [
1495,
0
] | [
1529,
19
] | python | en | ['en', 'en', 'en'] | True |
_first_line_re | () |
Return a regular expression based on first_line_re suitable for matching
strings.
|
Return a regular expression based on first_line_re suitable for matching
strings.
| def _first_line_re():
"""
Return a regular expression based on first_line_re suitable for matching
strings.
"""
if isinstance(first_line_re.pattern, str):
return first_line_re
# first_line_re in Python >=3.1.4 and >=3.2.1 is a bytes pattern.
return re.compile(first_line_re.pattern.d... | [
"def",
"_first_line_re",
"(",
")",
":",
"if",
"isinstance",
"(",
"first_line_re",
".",
"pattern",
",",
"str",
")",
":",
"return",
"first_line_re",
"# first_line_re in Python >=3.1.4 and >=3.2.1 is a bytes pattern.",
"return",
"re",
".",
"compile",
"(",
"first_line_re",
... | [
1666,
0
] | [
1675,
53
] | python | en | ['en', 'error', 'th'] | False |
update_dist_caches | (dist_path, fix_zipimporter_caches) |
Fix any globally cached `dist_path` related data
`dist_path` should be a path of a newly installed egg distribution (zipped
or unzipped).
sys.path_importer_cache contains finder objects that have been cached when
importing data from the original distribution. Any such finders need to be
clear... |
Fix any globally cached `dist_path` related data | def update_dist_caches(dist_path, fix_zipimporter_caches):
"""
Fix any globally cached `dist_path` related data
`dist_path` should be a path of a newly installed egg distribution (zipped
or unzipped).
sys.path_importer_cache contains finder objects that have been cached when
importing data fro... | [
"def",
"update_dist_caches",
"(",
"dist_path",
",",
"fix_zipimporter_caches",
")",
":",
"# There are several other known sources of stale zipimport.zipimporter",
"# instances that we do not clear here, but might if ever given a reason to",
"# do so:",
"# * Global setuptools pkg_resources.worki... | [
1687,
0
] | [
1766,
67
] | python | en | ['en', 'error', 'th'] | False |
_collect_zipimporter_cache_entries | (normalized_path, cache) |
Return zipimporter cache entry keys related to a given normalized path.
Alternative path spellings (e.g. those using different character case or
those using alternative path separators) related to the same path are
included. Any sub-path entries are included as well, i.e. those
corresponding to zi... |
Return zipimporter cache entry keys related to a given normalized path. | def _collect_zipimporter_cache_entries(normalized_path, cache):
"""
Return zipimporter cache entry keys related to a given normalized path.
Alternative path spellings (e.g. those using different character case or
those using alternative path separators) related to the same path are
included. Any su... | [
"def",
"_collect_zipimporter_cache_entries",
"(",
"normalized_path",
",",
"cache",
")",
":",
"result",
"=",
"[",
"]",
"prefix_len",
"=",
"len",
"(",
"normalized_path",
")",
"for",
"p",
"in",
"cache",
":",
"np",
"=",
"normalize_path",
"(",
"p",
")",
"if",
"... | [
1769,
0
] | [
1786,
17
] | python | en | ['en', 'error', 'th'] | False |
_update_zipimporter_cache | (normalized_path, cache, updater=None) |
Update zipimporter cache data for a given normalized path.
Any sub-path entries are processed as well, i.e. those corresponding to zip
archives embedded in other zip archives.
Given updater is a callable taking a cache entry key and the original entry
(after already removing the entry from the ca... |
Update zipimporter cache data for a given normalized path. | def _update_zipimporter_cache(normalized_path, cache, updater=None):
"""
Update zipimporter cache data for a given normalized path.
Any sub-path entries are processed as well, i.e. those corresponding to zip
archives embedded in other zip archives.
Given updater is a callable taking a cache entry ... | [
"def",
"_update_zipimporter_cache",
"(",
"normalized_path",
",",
"cache",
",",
"updater",
"=",
"None",
")",
":",
"for",
"p",
"in",
"_collect_zipimporter_cache_entries",
"(",
"normalized_path",
",",
"cache",
")",
":",
"# N.B. pypy's custom zipimport._zip_directory_cache im... | [
1789,
0
] | [
1818,
32
] | python | en | ['en', 'error', 'th'] | False |
is_python | (text, filename='<string>') | Is this string a valid Python script? | Is this string a valid Python script? | def is_python(text, filename='<string>'):
"Is this string a valid Python script?"
try:
compile(text, filename, 'exec')
except (SyntaxError, TypeError):
return False
else:
return True | [
"def",
"is_python",
"(",
"text",
",",
"filename",
"=",
"'<string>'",
")",
":",
"try",
":",
"compile",
"(",
"text",
",",
"filename",
",",
"'exec'",
")",
"except",
"(",
"SyntaxError",
",",
"TypeError",
")",
":",
"return",
"False",
"else",
":",
"return",
... | [
1866,
0
] | [
1873,
19
] | python | en | ['en', 'en', 'en'] | True |
is_sh | (executable) | Determine if the specified executable is a .sh (contains a #! line) | Determine if the specified executable is a .sh (contains a #! line) | def is_sh(executable):
"""Determine if the specified executable is a .sh (contains a #! line)"""
try:
with io.open(executable, encoding='latin-1') as fp:
magic = fp.read(2)
except (OSError, IOError):
return executable
return magic == '#!' | [
"def",
"is_sh",
"(",
"executable",
")",
":",
"try",
":",
"with",
"io",
".",
"open",
"(",
"executable",
",",
"encoding",
"=",
"'latin-1'",
")",
"as",
"fp",
":",
"magic",
"=",
"fp",
".",
"read",
"(",
"2",
")",
"except",
"(",
"OSError",
",",
"IOError"... | [
1876,
0
] | [
1883,
24
] | python | en | ['en', 'en', 'en'] | True |
nt_quote_arg | (arg) | Quote a command line argument according to Windows parsing rules | Quote a command line argument according to Windows parsing rules | def nt_quote_arg(arg):
"""Quote a command line argument according to Windows parsing rules"""
return subprocess.list2cmdline([arg]) | [
"def",
"nt_quote_arg",
"(",
"arg",
")",
":",
"return",
"subprocess",
".",
"list2cmdline",
"(",
"[",
"arg",
"]",
")"
] | [
1886,
0
] | [
1888,
41
] | python | en | ['en', 'en', 'en'] | True |
is_python_script | (script_text, filename) | Is this text, as a whole, a Python script? (as opposed to shell/bat/etc.
| Is this text, as a whole, a Python script? (as opposed to shell/bat/etc.
| def is_python_script(script_text, filename):
"""Is this text, as a whole, a Python script? (as opposed to shell/bat/etc.
"""
if filename.endswith('.py') or filename.endswith('.pyw'):
return True # extension says it's Python
if is_python(script_text, filename):
return True # it's syntac... | [
"def",
"is_python_script",
"(",
"script_text",
",",
"filename",
")",
":",
"if",
"filename",
".",
"endswith",
"(",
"'.py'",
")",
"or",
"filename",
".",
"endswith",
"(",
"'.pyw'",
")",
":",
"return",
"True",
"# extension says it's Python",
"if",
"is_python",
"("... | [
1891,
0
] | [
1902,
16
] | python | en | ['en', 'en', 'en'] | True |
get_win_launcher | (type) |
Load the Windows launcher (executable) suitable for launching a script.
`type` should be either 'cli' or 'gui'
Returns the executable as a byte string.
|
Load the Windows launcher (executable) suitable for launching a script. | def get_win_launcher(type):
"""
Load the Windows launcher (executable) suitable for launching a script.
`type` should be either 'cli' or 'gui'
Returns the executable as a byte string.
"""
launcher_fn = '%s.exe' % type
if is_64bit():
launcher_fn = launcher_fn.replace(".", "-64.")
... | [
"def",
"get_win_launcher",
"(",
"type",
")",
":",
"launcher_fn",
"=",
"'%s.exe'",
"%",
"type",
"if",
"is_64bit",
"(",
")",
":",
"launcher_fn",
"=",
"launcher_fn",
".",
"replace",
"(",
"\".\"",
",",
"\"-64.\"",
")",
"else",
":",
"launcher_fn",
"=",
"launche... | [
2229,
0
] | [
2242,
53
] | python | en | ['en', 'error', 'th'] | False |
easy_install._render_version | () |
Render the Setuptools version and installation details, then exit.
|
Render the Setuptools version and installation details, then exit.
| def _render_version():
"""
Render the Setuptools version and installation details, then exit.
"""
ver = '{}.{}'.format(*sys.version_info)
dist = get_distribution('setuptools')
tmpl = 'setuptools {dist.version} from {dist.location} (Python {ver})'
print(tmpl.format... | [
"def",
"_render_version",
"(",
")",
":",
"ver",
"=",
"'{}.{}'",
".",
"format",
"(",
"*",
"sys",
".",
"version_info",
")",
"dist",
"=",
"get_distribution",
"(",
"'setuptools'",
")",
"tmpl",
"=",
"'setuptools {dist.version} from {dist.location} (Python {ver})'",
"prin... | [
218,
4
] | [
226,
26
] | python | en | ['en', 'error', 'th'] | False |
easy_install._fix_install_dir_for_user_site | (self) |
Fix the install_dir if "--user" was used.
|
Fix the install_dir if "--user" was used.
| def _fix_install_dir_for_user_site(self):
"""
Fix the install_dir if "--user" was used.
"""
if not self.user or not site.ENABLE_USER_SITE:
return
self.create_home_path()
if self.install_userbase is None:
msg = "User base directory is not specified... | [
"def",
"_fix_install_dir_for_user_site",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"user",
"or",
"not",
"site",
".",
"ENABLE_USER_SITE",
":",
"return",
"self",
".",
"create_home_path",
"(",
")",
"if",
"self",
".",
"install_userbase",
"is",
"None",
":"... | [
355,
4
] | [
368,
39
] | python | en | ['en', 'error', 'th'] | False |
easy_install.expand_basedirs | (self) | Calls `os.path.expanduser` on install_base, install_platbase and
root. | Calls `os.path.expanduser` on install_base, install_platbase and
root. | def expand_basedirs(self):
"""Calls `os.path.expanduser` on install_base, install_platbase and
root."""
self._expand_attrs(['install_base', 'install_platbase', 'root']) | [
"def",
"expand_basedirs",
"(",
"self",
")",
":",
"self",
".",
"_expand_attrs",
"(",
"[",
"'install_base'",
",",
"'install_platbase'",
",",
"'root'",
"]",
")"
] | [
379,
4
] | [
382,
72
] | python | en | ['en', 'en', 'en'] | True |
easy_install.expand_dirs | (self) | Calls `os.path.expanduser` on install dirs. | Calls `os.path.expanduser` on install dirs. | def expand_dirs(self):
"""Calls `os.path.expanduser` on install dirs."""
dirs = [
'install_purelib',
'install_platlib',
'install_lib',
'install_headers',
'install_scripts',
'install_data',
]
self._expand_attrs(dirs) | [
"def",
"expand_dirs",
"(",
"self",
")",
":",
"dirs",
"=",
"[",
"'install_purelib'",
",",
"'install_platlib'",
",",
"'install_lib'",
",",
"'install_headers'",
",",
"'install_scripts'",
",",
"'install_data'",
",",
"]",
"self",
".",
"_expand_attrs",
"(",
"dirs",
")... | [
384,
4
] | [
394,
32
] | python | en | ['en', 'en', 'en'] | True |
easy_install.pseudo_tempname | (self) | Return a pseudo-tempname base in the install directory.
This code is intentionally naive; if a malicious party can write to
the target directory you're already in deep doodoo.
| Return a pseudo-tempname base in the install directory.
This code is intentionally naive; if a malicious party can write to
the target directory you're already in deep doodoo.
| def pseudo_tempname(self):
"""Return a pseudo-tempname base in the install directory.
This code is intentionally naive; if a malicious party can write to
the target directory you're already in deep doodoo.
"""
try:
pid = os.getpid()
except Exception:
... | [
"def",
"pseudo_tempname",
"(",
"self",
")",
":",
"try",
":",
"pid",
"=",
"os",
".",
"getpid",
"(",
")",
"except",
"Exception",
":",
"pid",
"=",
"random",
".",
"randint",
"(",
"0",
",",
"sys",
".",
"maxsize",
")",
"return",
"os",
".",
"path",
".",
... | [
425,
4
] | [
434,
75
] | python | en | ['en', 'en', 'en'] | True |
easy_install.check_site_dir | (self) | Verify that self.install_dir is .pth-capable dir, if needed | Verify that self.install_dir is .pth-capable dir, if needed | def check_site_dir(self):
"""Verify that self.install_dir is .pth-capable dir, if needed"""
instdir = normalize_path(self.install_dir)
pth_file = os.path.join(instdir, 'easy-install.pth')
if not os.path.exists(instdir):
try:
os.makedirs(instdir)
... | [
"def",
"check_site_dir",
"(",
"self",
")",
":",
"instdir",
"=",
"normalize_path",
"(",
"self",
".",
"install_dir",
")",
"pth_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"instdir",
",",
"'easy-install.pth'",
")",
"if",
"not",
"os",
".",
"path",
".",
... | [
439,
4
] | [
482,
34
] | python | en | ['en', 'en', 'en'] | True |
easy_install.check_pth_processing | (self) | Empirically verify whether .pth files are supported in inst. dir | Empirically verify whether .pth files are supported in inst. dir | def check_pth_processing(self):
"""Empirically verify whether .pth files are supported in inst. dir"""
instdir = self.install_dir
log.info("Checking .pth file support in %s", instdir)
pth_file = self.pseudo_tempname() + ".pth"
ok_file = pth_file + '.ok'
ok_exists = os.pat... | [
"def",
"check_pth_processing",
"(",
"self",
")",
":",
"instdir",
"=",
"self",
".",
"install_dir",
"log",
".",
"info",
"(",
"\"Checking .pth file support in %s\"",
",",
"instdir",
")",
"pth_file",
"=",
"self",
".",
"pseudo_tempname",
"(",
")",
"+",
"\".pth\"",
... | [
529,
4
] | [
586,
20
] | python | en | ['en', 'en', 'en'] | True |
easy_install.install_egg_scripts | (self, dist) | Write all the scripts for `dist`, unless scripts are excluded | Write all the scripts for `dist`, unless scripts are excluded | def install_egg_scripts(self, dist):
"""Write all the scripts for `dist`, unless scripts are excluded"""
if not self.exclude_scripts and dist.metadata_isdir('scripts'):
for script_name in dist.metadata_listdir('scripts'):
if dist.metadata_isdir('scripts/' + script_name):
... | [
"def",
"install_egg_scripts",
"(",
"self",
",",
"dist",
")",
":",
"if",
"not",
"self",
".",
"exclude_scripts",
"and",
"dist",
".",
"metadata_isdir",
"(",
"'scripts'",
")",
":",
"for",
"script_name",
"in",
"dist",
".",
"metadata_listdir",
"(",
"'scripts'",
")... | [
588,
4
] | [
600,
42
] | python | en | ['en', 'en', 'en'] | True |
easy_install.select_scheme | (self, name) | Sets the install directories by applying the install schemes. | Sets the install directories by applying the install schemes. | def select_scheme(self, name):
"""Sets the install directories by applying the install schemes."""
# it's the caller's problem if they supply a bad name!
scheme = INSTALL_SCHEMES[name]
for key in SCHEME_KEYS:
attrname = 'install_' + key
if getattr(self, attrname) ... | [
"def",
"select_scheme",
"(",
"self",
",",
"name",
")",
":",
"# it's the caller's problem if they supply a bad name!",
"scheme",
"=",
"INSTALL_SCHEMES",
"[",
"name",
"]",
"for",
"key",
"in",
"SCHEME_KEYS",
":",
"attrname",
"=",
"'install_'",
"+",
"key",
"if",
"geta... | [
706,
4
] | [
713,
52
] | python | en | ['en', 'en', 'en'] | True |
easy_install.install_script | (self, dist, script_name, script_text, dev_path=None) | Generate a legacy script wrapper and install it | Generate a legacy script wrapper and install it | def install_script(self, dist, script_name, script_text, dev_path=None):
"""Generate a legacy script wrapper and install it"""
spec = str(dist.as_requirement())
is_script = is_python_script(script_text, script_name)
if is_script:
body = self._load_template(dev_path) % locals... | [
"def",
"install_script",
"(",
"self",
",",
"dist",
",",
"script_name",
",",
"script_text",
",",
"dev_path",
"=",
"None",
")",
":",
"spec",
"=",
"str",
"(",
"dist",
".",
"as_requirement",
"(",
")",
")",
"is_script",
"=",
"is_python_script",
"(",
"script_tex... | [
792,
4
] | [
800,
67
] | python | en | ['en', 'en', 'en'] | True |
easy_install._load_template | (dev_path) |
There are a couple of template scripts in the package. This
function loads one of them and prepares it for use.
|
There are a couple of template scripts in the package. This
function loads one of them and prepares it for use.
| def _load_template(dev_path):
"""
There are a couple of template scripts in the package. This
function loads one of them and prepares it for use.
"""
# See https://github.com/pypa/setuptools/issues/134 for info
# on script file naming and downstream issues with SVR4
... | [
"def",
"_load_template",
"(",
"dev_path",
")",
":",
"# See https://github.com/pypa/setuptools/issues/134 for info",
"# on script file naming and downstream issues with SVR4",
"name",
"=",
"'script.tmpl'",
"if",
"dev_path",
":",
"name",
"=",
"name",
".",
"replace",
"(",
"'.tmp... | [
803,
4
] | [
815,
40
] | python | en | ['en', 'error', 'th'] | False |
easy_install.write_script | (self, script_name, contents, mode="t", blockers=()) | Write an executable file to the scripts directory | Write an executable file to the scripts directory | def write_script(self, script_name, contents, mode="t", blockers=()):
"""Write an executable file to the scripts directory"""
self.delete_blockers( # clean up old .py/.pyw w/o a script
[os.path.join(self.script_dir, x) for x in blockers]
)
log.info("Installing %s script to %... | [
"def",
"write_script",
"(",
"self",
",",
"script_name",
",",
"contents",
",",
"mode",
"=",
"\"t\"",
",",
"blockers",
"=",
"(",
")",
")",
":",
"self",
".",
"delete_blockers",
"(",
"# clean up old .py/.pyw w/o a script",
"[",
"os",
".",
"path",
".",
"join",
... | [
817,
4
] | [
835,
35
] | python | en | ['en', 'en', 'en'] | True |
easy_install.exe_to_egg | (self, dist_filename, egg_tmp) | Extract a bdist_wininst to the directories an egg would use | Extract a bdist_wininst to the directories an egg would use | def exe_to_egg(self, dist_filename, egg_tmp):
"""Extract a bdist_wininst to the directories an egg would use"""
# Check for .pth file and set up prefix translations
prefixes = get_exe_prefixes(dist_filename)
to_compile = []
native_libs = []
top_level = {}
def pro... | [
"def",
"exe_to_egg",
"(",
"self",
",",
"dist_filename",
",",
"egg_tmp",
")",
":",
"# Check for .pth file and set up prefix translations",
"prefixes",
"=",
"get_exe_prefixes",
"(",
"dist_filename",
")",
"to_compile",
"=",
"[",
"]",
"native_libs",
"=",
"[",
"]",
"top_... | [
988,
4
] | [
1039,
29
] | python | en | ['en', 'en', 'en'] | True |
easy_install.installation_report | (self, req, dist, what="Installed") | Helpful installation message for display to package users | Helpful installation message for display to package users | def installation_report(self, req, dist, what="Installed"):
"""Helpful installation message for display to package users"""
msg = "\n%(what)s %(eggloc)s%(extras)s"
if self.multi_version and not self.no_report:
msg += '\n' + self.__mv_warning
if self.install_dir not in map... | [
"def",
"installation_report",
"(",
"self",
",",
"req",
",",
"dist",
",",
"what",
"=",
"\"Installed\"",
")",
":",
"msg",
"=",
"\"\\n%(what)s %(eggloc)s%(extras)s\"",
"if",
"self",
".",
"multi_version",
"and",
"not",
"self",
".",
"no_report",
":",
"msg",
"+=",
... | [
1087,
4
] | [
1099,
29
] | python | en | ['en', 'en', 'en'] | True |
easy_install._set_fetcher_options | (self, base) |
When easy_install is about to run bdist_egg on a source dist, that
source dist might have 'setup_requires' directives, requiring
additional fetching. Ensure the fetcher options given to easy_install
are available to that command as well.
|
When easy_install is about to run bdist_egg on a source dist, that
source dist might have 'setup_requires' directives, requiring
additional fetching. Ensure the fetcher options given to easy_install
are available to that command as well.
| def _set_fetcher_options(self, base):
"""
When easy_install is about to run bdist_egg on a source dist, that
source dist might have 'setup_requires' directives, requiring
additional fetching. Ensure the fetcher options given to easy_install
are available to that command as well.
... | [
"def",
"_set_fetcher_options",
"(",
"self",
",",
"base",
")",
":",
"# find the fetch options from easy_install and write them out",
"# to the setup.cfg file.",
"ei_opts",
"=",
"self",
".",
"distribution",
".",
"get_option_dict",
"(",
"'easy_install'",
")",
".",
"copy",
"(... | [
1163,
4
] | [
1184,
50
] | python | en | ['en', 'error', 'th'] | False |
easy_install.create_home_path | (self) | Create directories under ~. | Create directories under ~. | def create_home_path(self):
"""Create directories under ~."""
if not self.user:
return
home = convert_path(os.path.expanduser("~"))
for name, path in self.config_vars.items():
if path.startswith(home) and not os.path.isdir(path):
self.debug_print("... | [
"def",
"create_home_path",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"user",
":",
"return",
"home",
"=",
"convert_path",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~\"",
")",
")",
"for",
"name",
",",
"path",
"in",
"self",
".",
"config_... | [
1298,
4
] | [
1306,
40
] | python | de | ['de', 'de', 'en'] | True |
PthDistributions.save | (self) | Write changed .pth file back to disk | Write changed .pth file back to disk | def save(self):
"""Write changed .pth file back to disk"""
if not self.dirty:
return
rel_paths = list(map(self.make_relative, self.paths))
if rel_paths:
log.debug("Saving %s", self.filename)
lines = self._wrap_lines(rel_paths)
data = '\n'.... | [
"def",
"save",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"dirty",
":",
"return",
"rel_paths",
"=",
"list",
"(",
"map",
"(",
"self",
".",
"make_relative",
",",
"self",
".",
"paths",
")",
")",
"if",
"rel_paths",
":",
"log",
".",
"debug",
"(",
... | [
1577,
4
] | [
1597,
26
] | python | en | ['en', 'en', 'en'] | True |
PthDistributions.add | (self, dist) | Add `dist` to the distribution map | Add `dist` to the distribution map | def add(self, dist):
"""Add `dist` to the distribution map"""
new_path = (
dist.location not in self.paths and (
dist.location not in self.sitedirs or
# account for '.' being in PYTHONPATH
dist.location == os.getcwd()
)
)
... | [
"def",
"add",
"(",
"self",
",",
"dist",
")",
":",
"new_path",
"=",
"(",
"dist",
".",
"location",
"not",
"in",
"self",
".",
"paths",
"and",
"(",
"dist",
".",
"location",
"not",
"in",
"self",
".",
"sitedirs",
"or",
"# account for '.' being in PYTHONPATH",
... | [
1603,
4
] | [
1615,
35
] | python | en | ['en', 'en', 'en'] | True |
PthDistributions.remove | (self, dist) | Remove `dist` from the distribution map | Remove `dist` from the distribution map | def remove(self, dist):
"""Remove `dist` from the distribution map"""
while dist.location in self.paths:
self.paths.remove(dist.location)
self.dirty = True
Environment.remove(self, dist) | [
"def",
"remove",
"(",
"self",
",",
"dist",
")",
":",
"while",
"dist",
".",
"location",
"in",
"self",
".",
"paths",
":",
"self",
".",
"paths",
".",
"remove",
"(",
"dist",
".",
"location",
")",
"self",
".",
"dirty",
"=",
"True",
"Environment",
".",
"... | [
1617,
4
] | [
1622,
38
] | python | en | ['en', 'en', 'en'] | True |
CommandSpec.best | (cls) |
Choose the best CommandSpec class based on environmental conditions.
|
Choose the best CommandSpec class based on environmental conditions.
| def best(cls):
"""
Choose the best CommandSpec class based on environmental conditions.
"""
return cls | [
"def",
"best",
"(",
"cls",
")",
":",
"return",
"cls"
] | [
1931,
4
] | [
1935,
18
] | python | en | ['en', 'error', 'th'] | False |
CommandSpec.from_param | (cls, param) |
Construct a CommandSpec from a parameter to build_scripts, which may
be None.
|
Construct a CommandSpec from a parameter to build_scripts, which may
be None.
| def from_param(cls, param):
"""
Construct a CommandSpec from a parameter to build_scripts, which may
be None.
"""
if isinstance(param, cls):
return param
if isinstance(param, list):
return cls(param)
if param is None:
return cls... | [
"def",
"from_param",
"(",
"cls",
",",
"param",
")",
":",
"if",
"isinstance",
"(",
"param",
",",
"cls",
")",
":",
"return",
"param",
"if",
"isinstance",
"(",
"param",
",",
"list",
")",
":",
"return",
"cls",
"(",
"param",
")",
"if",
"param",
"is",
"N... | [
1943,
4
] | [
1955,
37
] | python | en | ['en', 'error', 'th'] | False |
CommandSpec.from_string | (cls, string) |
Construct a command spec from a simple string representing a command
line parseable by shlex.split.
|
Construct a command spec from a simple string representing a command
line parseable by shlex.split.
| def from_string(cls, string):
"""
Construct a command spec from a simple string representing a command
line parseable by shlex.split.
"""
items = shlex.split(string, **cls.split_args)
return cls(items) | [
"def",
"from_string",
"(",
"cls",
",",
"string",
")",
":",
"items",
"=",
"shlex",
".",
"split",
"(",
"string",
",",
"*",
"*",
"cls",
".",
"split_args",
")",
"return",
"cls",
"(",
"items",
")"
] | [
1962,
4
] | [
1968,
25
] | python | en | ['en', 'error', 'th'] | False |
CommandSpec._extract_options | (orig_script) |
Extract any options from the first line of the script.
|
Extract any options from the first line of the script.
| def _extract_options(orig_script):
"""
Extract any options from the first line of the script.
"""
first = (orig_script + '\n').splitlines()[0]
match = _first_line_re().match(first)
options = match.group(1) or '' if match else ''
return options.strip() | [
"def",
"_extract_options",
"(",
"orig_script",
")",
":",
"first",
"=",
"(",
"orig_script",
"+",
"'\\n'",
")",
".",
"splitlines",
"(",
")",
"[",
"0",
"]",
"match",
"=",
"_first_line_re",
"(",
")",
".",
"match",
"(",
"first",
")",
"options",
"=",
"match"... | [
1977,
4
] | [
1984,
30
] | python | en | ['en', 'error', 'th'] | False |
ScriptWriter.get_args | (cls, dist, header=None) |
Yield write_script() argument tuples for a distribution's
console_scripts and gui_scripts entry points.
|
Yield write_script() argument tuples for a distribution's
console_scripts and gui_scripts entry points.
| def get_args(cls, dist, header=None):
"""
Yield write_script() argument tuples for a distribution's
console_scripts and gui_scripts entry points.
"""
if header is None:
header = cls.get_header()
spec = str(dist.as_requirement())
for type_ in 'console',... | [
"def",
"get_args",
"(",
"cls",
",",
"dist",
",",
"header",
"=",
"None",
")",
":",
"if",
"header",
"is",
"None",
":",
"header",
"=",
"cls",
".",
"get_header",
"(",
")",
"spec",
"=",
"str",
"(",
"dist",
".",
"as_requirement",
"(",
")",
")",
"for",
... | [
2073,
4
] | [
2088,
29
] | python | en | ['en', 'error', 'th'] | False |
ScriptWriter._ensure_safe_name | (name) |
Prevent paths in *_scripts entry point names.
|
Prevent paths in *_scripts entry point names.
| def _ensure_safe_name(name):
"""
Prevent paths in *_scripts entry point names.
"""
has_path_sep = re.search(r'[\\/]', name)
if has_path_sep:
raise ValueError("Path separators not allowed in script names") | [
"def",
"_ensure_safe_name",
"(",
"name",
")",
":",
"has_path_sep",
"=",
"re",
".",
"search",
"(",
"r'[\\\\/]'",
",",
"name",
")",
"if",
"has_path_sep",
":",
"raise",
"ValueError",
"(",
"\"Path separators not allowed in script names\"",
")"
] | [
2091,
4
] | [
2097,
75
] | python | en | ['en', 'error', 'th'] | False |
ScriptWriter.best | (cls) |
Select the best ScriptWriter for this environment.
|
Select the best ScriptWriter for this environment.
| def best(cls):
"""
Select the best ScriptWriter for this environment.
"""
if sys.platform == 'win32' or (os.name == 'java' and os._name == 'nt'):
return WindowsScriptWriter.best()
else:
return cls | [
"def",
"best",
"(",
"cls",
")",
":",
"if",
"sys",
".",
"platform",
"==",
"'win32'",
"or",
"(",
"os",
".",
"name",
"==",
"'java'",
"and",
"os",
".",
"_name",
"==",
"'nt'",
")",
":",
"return",
"WindowsScriptWriter",
".",
"best",
"(",
")",
"else",
":"... | [
2106,
4
] | [
2113,
22
] | python | en | ['en', 'error', 'th'] | False |
ScriptWriter.get_header | (cls, script_text="", executable=None) | Create a #! line, getting options (if any) from script_text | Create a #! line, getting options (if any) from script_text | def get_header(cls, script_text="", executable=None):
"""Create a #! line, getting options (if any) from script_text"""
cmd = cls.command_spec_class.best().from_param(executable)
cmd.install_options(script_text)
return cmd.as_header() | [
"def",
"get_header",
"(",
"cls",
",",
"script_text",
"=",
"\"\"",
",",
"executable",
"=",
"None",
")",
":",
"cmd",
"=",
"cls",
".",
"command_spec_class",
".",
"best",
"(",
")",
".",
"from_param",
"(",
"executable",
")",
"cmd",
".",
"install_options",
"("... | [
2121,
4
] | [
2125,
30
] | python | en | ['en', 'en', 'en'] | True |
WindowsScriptWriter.best | (cls) |
Select the best ScriptWriter suitable for Windows
|
Select the best ScriptWriter suitable for Windows
| def best(cls):
"""
Select the best ScriptWriter suitable for Windows
"""
writer_lookup = dict(
executable=WindowsExecutableLauncherWriter,
natural=cls,
)
# for compatibility, use the executable launcher by default
launcher = os.environ.get(... | [
"def",
"best",
"(",
"cls",
")",
":",
"writer_lookup",
"=",
"dict",
"(",
"executable",
"=",
"WindowsExecutableLauncherWriter",
",",
"natural",
"=",
"cls",
",",
")",
"# for compatibility, use the executable launcher by default",
"launcher",
"=",
"os",
".",
"environ",
... | [
2138,
4
] | [
2148,
38
] | python | en | ['en', 'error', 'th'] | False |
WindowsScriptWriter._get_script_args | (cls, type_, name, header, script_text) | For Windows, add a .py extension | For Windows, add a .py extension | def _get_script_args(cls, type_, name, header, script_text):
"For Windows, add a .py extension"
ext = dict(console='.pya', gui='.pyw')[type_]
if ext not in os.environ['PATHEXT'].lower().split(';'):
msg = (
"{ext} not listed in PATHEXT; scripts will not be "
... | [
"def",
"_get_script_args",
"(",
"cls",
",",
"type_",
",",
"name",
",",
"header",
",",
"script_text",
")",
":",
"ext",
"=",
"dict",
"(",
"console",
"=",
"'.pya'",
",",
"gui",
"=",
"'.pyw'",
")",
"[",
"type_",
"]",
"if",
"ext",
"not",
"in",
"os",
"."... | [
2151,
4
] | [
2164,
61
] | python | en | ['en', 'en', 'en'] | True |
WindowsScriptWriter._adjust_header | (cls, type_, orig_header) |
Make sure 'pythonw' is used for gui and and 'python' is used for
console (regardless of what sys.executable is).
|
Make sure 'pythonw' is used for gui and and 'python' is used for
console (regardless of what sys.executable is).
| def _adjust_header(cls, type_, orig_header):
"""
Make sure 'pythonw' is used for gui and and 'python' is used for
console (regardless of what sys.executable is).
"""
pattern = 'pythonw.exe'
repl = 'python.exe'
if type_ == 'gui':
pattern, repl = repl, p... | [
"def",
"_adjust_header",
"(",
"cls",
",",
"type_",
",",
"orig_header",
")",
":",
"pattern",
"=",
"'pythonw.exe'",
"repl",
"=",
"'python.exe'",
"if",
"type_",
"==",
"'gui'",
":",
"pattern",
",",
"repl",
"=",
"repl",
",",
"pattern",
"pattern_ob",
"=",
"re",
... | [
2167,
4
] | [
2178,
73
] | python | en | ['en', 'error', 'th'] | False |
WindowsScriptWriter._use_header | (new_header) |
Should _adjust_header use the replaced header?
On non-windows systems, always use. On
Windows systems, only use the replaced header if it resolves
to an executable on the system.
|
Should _adjust_header use the replaced header? | def _use_header(new_header):
"""
Should _adjust_header use the replaced header?
On non-windows systems, always use. On
Windows systems, only use the replaced header if it resolves
to an executable on the system.
"""
clean_header = new_header[2:-1].strip('"')
... | [
"def",
"_use_header",
"(",
"new_header",
")",
":",
"clean_header",
"=",
"new_header",
"[",
"2",
":",
"-",
"1",
"]",
".",
"strip",
"(",
"'\"'",
")",
"return",
"sys",
".",
"platform",
"!=",
"'win32'",
"or",
"find_executable",
"(",
"clean_header",
")"
] | [
2181,
4
] | [
2190,
71
] | python | en | ['en', 'error', 'th'] | False |
WindowsExecutableLauncherWriter._get_script_args | (cls, type_, name, header, script_text) |
For Windows, add a .py extension and an .exe launcher
|
For Windows, add a .py extension and an .exe launcher
| def _get_script_args(cls, type_, name, header, script_text):
"""
For Windows, add a .py extension and an .exe launcher
"""
if type_ == 'gui':
launcher_type = 'gui'
ext = '-script.pyw'
old = ['.pyw']
else:
launcher_type = 'cli'
... | [
"def",
"_get_script_args",
"(",
"cls",
",",
"type_",
",",
"name",
",",
"header",
",",
"script_text",
")",
":",
"if",
"type_",
"==",
"'gui'",
":",
"launcher_type",
"=",
"'gui'",
"ext",
"=",
"'-script.pyw'",
"old",
"=",
"[",
"'.pyw'",
"]",
"else",
":",
"... | [
2195,
4
] | [
2221,
61
] | python | en | ['en', 'error', 'th'] | False |
Jcourse.setUp | (self) | Setting up test. | Setting up test. | def setUp(self):
"""Setting up test."""
self.server_url = self.conf_get('main', 'url')
credential_host = self.conf_get('credential', 'host')
credential_port = self.conf_getInt('credential', 'port')
self.username, self.pwd = xmlrpc_get_credential(
credential_host, cre... | [
"def",
"setUp",
"(",
"self",
")",
":",
"self",
".",
"server_url",
"=",
"self",
".",
"conf_get",
"(",
"'main'",
",",
"'url'",
")",
"credential_host",
"=",
"self",
".",
"conf_get",
"(",
"'credential'",
",",
"'host'",
")",
"credential_port",
"=",
"self",
".... | [
14,
4
] | [
21,
55
] | python | en | ['en', 'en', 'en'] | True |
RequestException.__init__ | (self, *args, **kwargs) | Initialize RequestException with `request` and `response` objects. | Initialize RequestException with `request` and `response` objects. | def __init__(self, *args, **kwargs):
"""Initialize RequestException with `request` and `response` objects."""
response = kwargs.pop('response', None)
self.response = response
self.request = kwargs.pop('request', None)
if (response is not None and not self.request and
... | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"kwargs",
".",
"pop",
"(",
"'response'",
",",
"None",
")",
"self",
".",
"response",
"=",
"response",
"self",
".",
"request",
"=",
"kwargs",
".",
"... | [
16,
4
] | [
24,
63
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.