repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
twisted/axiom | axiom/scheduler.py | upgradeParentHook1to2 | def upgradeParentHook1to2(oldHook):
"""
Add the scheduler attribute to the given L{_SubSchedulerParentHook}.
"""
newHook = oldHook.upgradeVersion(
oldHook.typeName, 1, 2,
loginAccount=oldHook.loginAccount,
scheduledAt=oldHook.scheduledAt,
scheduler=oldHook.store.findFirst... | python | def upgradeParentHook1to2(oldHook):
"""
Add the scheduler attribute to the given L{_SubSchedulerParentHook}.
"""
newHook = oldHook.upgradeVersion(
oldHook.typeName, 1, 2,
loginAccount=oldHook.loginAccount,
scheduledAt=oldHook.scheduledAt,
scheduler=oldHook.store.findFirst... | [
"def",
"upgradeParentHook1to2",
"(",
"oldHook",
")",
":",
"newHook",
"=",
"oldHook",
".",
"upgradeVersion",
"(",
"oldHook",
".",
"typeName",
",",
"1",
",",
"2",
",",
"loginAccount",
"=",
"oldHook",
".",
"loginAccount",
",",
"scheduledAt",
"=",
"oldHook",
"."... | Add the scheduler attribute to the given L{_SubSchedulerParentHook}. | [
"Add",
"the",
"scheduler",
"attribute",
"to",
"the",
"given",
"L",
"{",
"_SubSchedulerParentHook",
"}",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/scheduler.py#L484-L493 |
twisted/axiom | axiom/scheduler.py | upgradeParentHook3to4 | def upgradeParentHook3to4(old):
"""
Copy C{loginAccount} to C{subStore} and remove the installation marker.
"""
new = old.upgradeVersion(
old.typeName, 3, 4, subStore=old.loginAccount)
uninstallFrom(new, new.store)
return new | python | def upgradeParentHook3to4(old):
"""
Copy C{loginAccount} to C{subStore} and remove the installation marker.
"""
new = old.upgradeVersion(
old.typeName, 3, 4, subStore=old.loginAccount)
uninstallFrom(new, new.store)
return new | [
"def",
"upgradeParentHook3to4",
"(",
"old",
")",
":",
"new",
"=",
"old",
".",
"upgradeVersion",
"(",
"old",
".",
"typeName",
",",
"3",
",",
"4",
",",
"subStore",
"=",
"old",
".",
"loginAccount",
")",
"uninstallFrom",
"(",
"new",
",",
"new",
".",
"store... | Copy C{loginAccount} to C{subStore} and remove the installation marker. | [
"Copy",
"C",
"{",
"loginAccount",
"}",
"to",
"C",
"{",
"subStore",
"}",
"and",
"remove",
"the",
"installation",
"marker",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/scheduler.py#L518-L525 |
twisted/axiom | axiom/scheduler.py | TimedEvent.invokeRunnable | def invokeRunnable(self):
"""
Run my runnable, and reschedule or delete myself based on its result.
Must be run in a transaction.
"""
runnable = self.runnable
if runnable is None:
self.deleteFromStore()
else:
try:
self.runni... | python | def invokeRunnable(self):
"""
Run my runnable, and reschedule or delete myself based on its result.
Must be run in a transaction.
"""
runnable = self.runnable
if runnable is None:
self.deleteFromStore()
else:
try:
self.runni... | [
"def",
"invokeRunnable",
"(",
"self",
")",
":",
"runnable",
"=",
"self",
".",
"runnable",
"if",
"runnable",
"is",
"None",
":",
"self",
".",
"deleteFromStore",
"(",
")",
"else",
":",
"try",
":",
"self",
".",
"running",
"=",
"True",
"newTime",
"=",
"runn... | Run my runnable, and reschedule or delete myself based on its result.
Must be run in a transaction. | [
"Run",
"my",
"runnable",
"and",
"reschedule",
"or",
"delete",
"myself",
"based",
"on",
"its",
"result",
".",
"Must",
"be",
"run",
"in",
"a",
"transaction",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/scheduler.py#L84-L98 |
twisted/axiom | axiom/scheduler.py | TimedEvent.handleError | def handleError(self, now, failureObj):
""" An error occurred running my runnable. Check my runnable for an
error-handling method called 'timedEventErrorHandler' that will take
the given failure as an argument, and execute that if available:
otherwise, create a TimedEventFailureLog with... | python | def handleError(self, now, failureObj):
""" An error occurred running my runnable. Check my runnable for an
error-handling method called 'timedEventErrorHandler' that will take
the given failure as an argument, and execute that if available:
otherwise, create a TimedEventFailureLog with... | [
"def",
"handleError",
"(",
"self",
",",
"now",
",",
"failureObj",
")",
":",
"errorHandler",
"=",
"getattr",
"(",
"self",
".",
"runnable",
",",
"'timedEventErrorHandler'",
",",
"None",
")",
"if",
"errorHandler",
"is",
"not",
"None",
":",
"self",
".",
"_resc... | An error occurred running my runnable. Check my runnable for an
error-handling method called 'timedEventErrorHandler' that will take
the given failure as an argument, and execute that if available:
otherwise, create a TimedEventFailureLog with information about what
happened to this eve... | [
"An",
"error",
"occurred",
"running",
"my",
"runnable",
".",
"Check",
"my",
"runnable",
"for",
"an",
"error",
"-",
"handling",
"method",
"called",
"timedEventErrorHandler",
"that",
"will",
"take",
"the",
"given",
"failure",
"as",
"an",
"argument",
"and",
"exec... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/scheduler.py#L101-L114 |
twisted/axiom | axiom/scheduler.py | SchedulerMixin.unscheduleFirst | def unscheduleFirst(self, runnable):
"""
Remove from given item from the schedule.
If runnable is scheduled to run multiple times, only the temporally first
is removed.
"""
for evt in self.store.query(TimedEvent, TimedEvent.runnable == runnable, sort=TimedEvent.time.asce... | python | def unscheduleFirst(self, runnable):
"""
Remove from given item from the schedule.
If runnable is scheduled to run multiple times, only the temporally first
is removed.
"""
for evt in self.store.query(TimedEvent, TimedEvent.runnable == runnable, sort=TimedEvent.time.asce... | [
"def",
"unscheduleFirst",
"(",
"self",
",",
"runnable",
")",
":",
"for",
"evt",
"in",
"self",
".",
"store",
".",
"query",
"(",
"TimedEvent",
",",
"TimedEvent",
".",
"runnable",
"==",
"runnable",
",",
"sort",
"=",
"TimedEvent",
".",
"time",
".",
"ascendin... | Remove from given item from the schedule.
If runnable is scheduled to run multiple times, only the temporally first
is removed. | [
"Remove",
"from",
"given",
"item",
"from",
"the",
"schedule",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/scheduler.py#L200-L209 |
twisted/axiom | axiom/scheduler.py | SchedulerMixin.scheduledTimes | def scheduledTimes(self, runnable):
"""
Return an iterable of the times at which the given item is scheduled to
run.
"""
events = self.store.query(
TimedEvent, TimedEvent.runnable == runnable)
return (event.time for event in events if not event.running) | python | def scheduledTimes(self, runnable):
"""
Return an iterable of the times at which the given item is scheduled to
run.
"""
events = self.store.query(
TimedEvent, TimedEvent.runnable == runnable)
return (event.time for event in events if not event.running) | [
"def",
"scheduledTimes",
"(",
"self",
",",
"runnable",
")",
":",
"events",
"=",
"self",
".",
"store",
".",
"query",
"(",
"TimedEvent",
",",
"TimedEvent",
".",
"runnable",
"==",
"runnable",
")",
"return",
"(",
"event",
".",
"time",
"for",
"event",
"in",
... | Return an iterable of the times at which the given item is scheduled to
run. | [
"Return",
"an",
"iterable",
"of",
"the",
"times",
"at",
"which",
"the",
"given",
"item",
"is",
"scheduled",
"to",
"run",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/scheduler.py#L217-L224 |
twisted/axiom | axiom/scheduler.py | _SiteScheduler.startService | def startService(self):
"""
Start calling persistent timed events whose time has come.
"""
super(_SiteScheduler, self).startService()
self._transientSchedule(self.now(), self.now()) | python | def startService(self):
"""
Start calling persistent timed events whose time has come.
"""
super(_SiteScheduler, self).startService()
self._transientSchedule(self.now(), self.now()) | [
"def",
"startService",
"(",
"self",
")",
":",
"super",
"(",
"_SiteScheduler",
",",
"self",
")",
".",
"startService",
"(",
")",
"self",
".",
"_transientSchedule",
"(",
"self",
".",
"now",
"(",
")",
",",
"self",
".",
"now",
"(",
")",
")"
] | Start calling persistent timed events whose time has come. | [
"Start",
"calling",
"persistent",
"timed",
"events",
"whose",
"time",
"has",
"come",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/scheduler.py#L245-L250 |
twisted/axiom | axiom/scheduler.py | _SiteScheduler.stopService | def stopService(self):
"""
Stop calling persistent timed events.
"""
super(_SiteScheduler, self).stopService()
if self.timer is not None:
self.timer.cancel()
self.timer = None | python | def stopService(self):
"""
Stop calling persistent timed events.
"""
super(_SiteScheduler, self).stopService()
if self.timer is not None:
self.timer.cancel()
self.timer = None | [
"def",
"stopService",
"(",
"self",
")",
":",
"super",
"(",
"_SiteScheduler",
",",
"self",
")",
".",
"stopService",
"(",
")",
"if",
"self",
".",
"timer",
"is",
"not",
"None",
":",
"self",
".",
"timer",
".",
"cancel",
"(",
")",
"self",
".",
"timer",
... | Stop calling persistent timed events. | [
"Stop",
"calling",
"persistent",
"timed",
"events",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/scheduler.py#L253-L260 |
twisted/axiom | axiom/scheduler.py | _SiteScheduler._transientSchedule | def _transientSchedule(self, when, now):
"""
If the service is currently running, schedule a tick to happen no
later than C{when}.
@param when: The time at which to tick.
@type when: L{epsilon.extime.Time}
@param now: The current time.
@type now: L{epsilon.extim... | python | def _transientSchedule(self, when, now):
"""
If the service is currently running, schedule a tick to happen no
later than C{when}.
@param when: The time at which to tick.
@type when: L{epsilon.extime.Time}
@param now: The current time.
@type now: L{epsilon.extim... | [
"def",
"_transientSchedule",
"(",
"self",
",",
"when",
",",
"now",
")",
":",
"if",
"not",
"self",
".",
"running",
":",
"return",
"if",
"self",
".",
"timer",
"is",
"not",
"None",
":",
"if",
"self",
".",
"timer",
".",
"getTime",
"(",
")",
"<",
"when"... | If the service is currently running, schedule a tick to happen no
later than C{when}.
@param when: The time at which to tick.
@type when: L{epsilon.extime.Time}
@param now: The current time.
@type now: L{epsilon.extime.Time} | [
"If",
"the",
"service",
"is",
"currently",
"running",
"schedule",
"a",
"tick",
"to",
"happen",
"no",
"later",
"than",
"C",
"{",
"when",
"}",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/scheduler.py#L268-L293 |
twisted/axiom | axiom/scheduler.py | _UserScheduler._transientSchedule | def _transientSchedule(self, when, now):
"""
If this service's store is attached to its parent, ask the parent to
schedule this substore to tick at the given time.
@param when: The time at which to tick.
@type when: L{epsilon.extime.Time}
@param now: Present for signatu... | python | def _transientSchedule(self, when, now):
"""
If this service's store is attached to its parent, ask the parent to
schedule this substore to tick at the given time.
@param when: The time at which to tick.
@type when: L{epsilon.extime.Time}
@param now: Present for signatu... | [
"def",
"_transientSchedule",
"(",
"self",
",",
"when",
",",
"now",
")",
":",
"if",
"self",
".",
"store",
".",
"parent",
"is",
"not",
"None",
":",
"subStore",
"=",
"self",
".",
"store",
".",
"parent",
".",
"getItemByID",
"(",
"self",
".",
"store",
"."... | If this service's store is attached to its parent, ask the parent to
schedule this substore to tick at the given time.
@param when: The time at which to tick.
@type when: L{epsilon.extime.Time}
@param now: Present for signature compatibility with
L{_SiteScheduler._transient... | [
"If",
"this",
"service",
"s",
"store",
"is",
"attached",
"to",
"its",
"parent",
"ask",
"the",
"parent",
"to",
"schedule",
"this",
"substore",
"to",
"tick",
"at",
"the",
"given",
"time",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/scheduler.py#L314-L330 |
twisted/axiom | axiom/scheduler.py | _UserScheduler.migrateDown | def migrateDown(self):
"""
Remove the components in the site store for this SubScheduler.
"""
subStore = self.store.parent.getItemByID(self.store.idInParent)
ssph = self.store.parent.findUnique(
_SubSchedulerParentHook,
_SubSchedulerParentHook.subStore == ... | python | def migrateDown(self):
"""
Remove the components in the site store for this SubScheduler.
"""
subStore = self.store.parent.getItemByID(self.store.idInParent)
ssph = self.store.parent.findUnique(
_SubSchedulerParentHook,
_SubSchedulerParentHook.subStore == ... | [
"def",
"migrateDown",
"(",
"self",
")",
":",
"subStore",
"=",
"self",
".",
"store",
".",
"parent",
".",
"getItemByID",
"(",
"self",
".",
"store",
".",
"idInParent",
")",
"ssph",
"=",
"self",
".",
"store",
".",
"parent",
".",
"findUnique",
"(",
"_SubSch... | Remove the components in the site store for this SubScheduler. | [
"Remove",
"the",
"components",
"in",
"the",
"site",
"store",
"for",
"this",
"SubScheduler",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/scheduler.py#L333-L348 |
twisted/axiom | axiom/scheduler.py | _UserScheduler.migrateUp | def migrateUp(self):
"""
Recreate the hooks in the site store to trigger this SubScheduler.
"""
te = self.store.findFirst(TimedEvent, sort=TimedEvent.time.descending)
if te is not None:
self._transientSchedule(te.time, None) | python | def migrateUp(self):
"""
Recreate the hooks in the site store to trigger this SubScheduler.
"""
te = self.store.findFirst(TimedEvent, sort=TimedEvent.time.descending)
if te is not None:
self._transientSchedule(te.time, None) | [
"def",
"migrateUp",
"(",
"self",
")",
":",
"te",
"=",
"self",
".",
"store",
".",
"findFirst",
"(",
"TimedEvent",
",",
"sort",
"=",
"TimedEvent",
".",
"time",
".",
"descending",
")",
"if",
"te",
"is",
"not",
"None",
":",
"self",
".",
"_transientSchedule... | Recreate the hooks in the site store to trigger this SubScheduler. | [
"Recreate",
"the",
"hooks",
"in",
"the",
"site",
"store",
"to",
"trigger",
"this",
"SubScheduler",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/scheduler.py#L351-L357 |
twisted/axiom | axiom/scheduler.py | _SchedulerCompatMixin.activate | def activate(self):
"""
Whenever L{Scheduler} or L{SubScheduler} is created, either newly or
when loaded from a database, emit a deprecation warning referring
people to L{IScheduler}.
"""
# This is unfortunate. Perhaps it is the best thing which works (it is
# th... | python | def activate(self):
"""
Whenever L{Scheduler} or L{SubScheduler} is created, either newly or
when loaded from a database, emit a deprecation warning referring
people to L{IScheduler}.
"""
# This is unfortunate. Perhaps it is the best thing which works (it is
# th... | [
"def",
"activate",
"(",
"self",
")",
":",
"# This is unfortunate. Perhaps it is the best thing which works (it is",
"# the first I found). -exarkun",
"if",
"'_axiom_memory_dummy'",
"in",
"vars",
"(",
"self",
")",
":",
"stacklevel",
"=",
"7",
"else",
":",
"stacklevel",
"=... | Whenever L{Scheduler} or L{SubScheduler} is created, either newly or
when loaded from a database, emit a deprecation warning referring
people to L{IScheduler}. | [
"Whenever",
"L",
"{",
"Scheduler",
"}",
"or",
"L",
"{",
"SubScheduler",
"}",
"is",
"created",
"either",
"newly",
"or",
"when",
"loaded",
"from",
"a",
"database",
"emit",
"a",
"deprecation",
"warning",
"referring",
"people",
"to",
"L",
"{",
"IScheduler",
"}... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/scheduler.py#L391-L407 |
twisted/axiom | axiom/scheduler.py | _SubSchedulerParentHook._schedule | def _schedule(self, when):
"""
Ensure that this hook is scheduled to run at or before C{when}.
"""
sched = IScheduler(self.store)
for scheduledAt in sched.scheduledTimes(self):
if when < scheduledAt:
sched.reschedule(self, scheduledAt, when)
... | python | def _schedule(self, when):
"""
Ensure that this hook is scheduled to run at or before C{when}.
"""
sched = IScheduler(self.store)
for scheduledAt in sched.scheduledTimes(self):
if when < scheduledAt:
sched.reschedule(self, scheduledAt, when)
... | [
"def",
"_schedule",
"(",
"self",
",",
"when",
")",
":",
"sched",
"=",
"IScheduler",
"(",
"self",
".",
"store",
")",
"for",
"scheduledAt",
"in",
"sched",
".",
"scheduledTimes",
"(",
"self",
")",
":",
"if",
"when",
"<",
"scheduledAt",
":",
"sched",
".",
... | Ensure that this hook is scheduled to run at or before C{when}. | [
"Ensure",
"that",
"this",
"hook",
"is",
"scheduled",
"to",
"run",
"at",
"or",
"before",
"C",
"{",
"when",
"}",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/scheduler.py#L471-L481 |
davidmcclure/textplot | textplot/helpers.py | build_graph | def build_graph(path, term_depth=1000, skim_depth=10,
d_weights=False, **kwargs):
"""
Tokenize a text, index a term matrix, and build out a graph.
Args:
path (str): The file path.
term_depth (int): Consider the N most frequent terms.
skim_depth (int): Connect each w... | python | def build_graph(path, term_depth=1000, skim_depth=10,
d_weights=False, **kwargs):
"""
Tokenize a text, index a term matrix, and build out a graph.
Args:
path (str): The file path.
term_depth (int): Consider the N most frequent terms.
skim_depth (int): Connect each w... | [
"def",
"build_graph",
"(",
"path",
",",
"term_depth",
"=",
"1000",
",",
"skim_depth",
"=",
"10",
",",
"d_weights",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# Tokenize text.",
"click",
".",
"echo",
"(",
"'\\nTokenizing text...'",
")",
"t",
"=",
"... | Tokenize a text, index a term matrix, and build out a graph.
Args:
path (str): The file path.
term_depth (int): Consider the N most frequent terms.
skim_depth (int): Connect each word to the N closest siblings.
d_weights (bool): If true, give "close" nodes low weights.
Returns:... | [
"Tokenize",
"a",
"text",
"index",
"a",
"term",
"matrix",
"and",
"build",
"out",
"a",
"graph",
"."
] | train | https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/helpers.py#L10-L43 |
davidmcclure/textplot | textplot/graphs.py | Graph.draw_spring | def draw_spring(self, **kwargs):
"""
Render a spring layout.
"""
nx.draw_spring(
self.graph,
with_labels=True,
font_size=10,
edge_color='#dddddd',
node_size=0,
**kwargs
)
plt.show() | python | def draw_spring(self, **kwargs):
"""
Render a spring layout.
"""
nx.draw_spring(
self.graph,
with_labels=True,
font_size=10,
edge_color='#dddddd',
node_size=0,
**kwargs
)
plt.show() | [
"def",
"draw_spring",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"nx",
".",
"draw_spring",
"(",
"self",
".",
"graph",
",",
"with_labels",
"=",
"True",
",",
"font_size",
"=",
"10",
",",
"edge_color",
"=",
"'#dddddd'",
",",
"node_size",
"=",
"0",
... | Render a spring layout. | [
"Render",
"a",
"spring",
"layout",
"."
] | train | https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/graphs.py#L27-L42 |
davidmcclure/textplot | textplot/graphs.py | Skimmer.build | def build(self, text, matrix, skim_depth=10, d_weights=False):
"""
1. For each term in the passed matrix, score its KDE similarity with
all other indexed terms.
2. With the ordered stack of similarities in hand, skim off the top X
pairs and add them as edges.
Args:
... | python | def build(self, text, matrix, skim_depth=10, d_weights=False):
"""
1. For each term in the passed matrix, score its KDE similarity with
all other indexed terms.
2. With the ordered stack of similarities in hand, skim off the top X
pairs and add them as edges.
Args:
... | [
"def",
"build",
"(",
"self",
",",
"text",
",",
"matrix",
",",
"skim_depth",
"=",
"10",
",",
"d_weights",
"=",
"False",
")",
":",
"for",
"anchor",
"in",
"bar",
"(",
"matrix",
".",
"keys",
")",
":",
"n1",
"=",
"text",
".",
"unstem",
"(",
"anchor",
... | 1. For each term in the passed matrix, score its KDE similarity with
all other indexed terms.
2. With the ordered stack of similarities in hand, skim off the top X
pairs and add them as edges.
Args:
text (Text): The source text instance.
matrix (Matrix): An inde... | [
"1",
".",
"For",
"each",
"term",
"in",
"the",
"passed",
"matrix",
"score",
"its",
"KDE",
"similarity",
"with",
"all",
"other",
"indexed",
"terms",
"."
] | train | https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/graphs.py#L72-L104 |
Pylons/plaster_pastedeploy | src/plaster_pastedeploy/__init__.py | Loader.get_settings | def get_settings(self, section=None, defaults=None):
"""
Gets a named section from the configuration source.
:param section: a :class:`str` representing the section you want to
retrieve from the configuration source. If ``None`` this will
fallback to the :attr:`plaster.P... | python | def get_settings(self, section=None, defaults=None):
"""
Gets a named section from the configuration source.
:param section: a :class:`str` representing the section you want to
retrieve from the configuration source. If ``None`` this will
fallback to the :attr:`plaster.P... | [
"def",
"get_settings",
"(",
"self",
",",
"section",
"=",
"None",
",",
"defaults",
"=",
"None",
")",
":",
"# This is a partial reimplementation of",
"# ``paste.deploy.loadwsgi.ConfigLoader:get_context`` which supports",
"# \"set\" and \"get\" options and filters out any other globals"... | Gets a named section from the configuration source.
:param section: a :class:`str` representing the section you want to
retrieve from the configuration source. If ``None`` this will
fallback to the :attr:`plaster.PlasterURL.fragment`.
:param defaults: a :class:`dict` that will g... | [
"Gets",
"a",
"named",
"section",
"from",
"the",
"configuration",
"source",
"."
] | train | https://github.com/Pylons/plaster_pastedeploy/blob/72a08f3fb6d11a0b039f381ade83f045668cfcb0/src/plaster_pastedeploy/__init__.py#L61-L107 |
Pylons/plaster_pastedeploy | src/plaster_pastedeploy/__init__.py | Loader.get_wsgi_app | def get_wsgi_app(self, name=None, defaults=None):
"""
Reads the configuration source and finds and loads a WSGI
application defined by the entry with name ``name`` per the
PasteDeploy configuration format and loading mechanism.
:param name: The named WSGI app to find, load and r... | python | def get_wsgi_app(self, name=None, defaults=None):
"""
Reads the configuration source and finds and loads a WSGI
application defined by the entry with name ``name`` per the
PasteDeploy configuration format and loading mechanism.
:param name: The named WSGI app to find, load and r... | [
"def",
"get_wsgi_app",
"(",
"self",
",",
"name",
"=",
"None",
",",
"defaults",
"=",
"None",
")",
":",
"name",
"=",
"self",
".",
"_maybe_get_default_name",
"(",
"name",
")",
"defaults",
"=",
"self",
".",
"_get_defaults",
"(",
"defaults",
")",
"return",
"l... | Reads the configuration source and finds and loads a WSGI
application defined by the entry with name ``name`` per the
PasteDeploy configuration format and loading mechanism.
:param name: The named WSGI app to find, load and return. Defaults to
``None`` which becomes ``main`` inside
... | [
"Reads",
"the",
"configuration",
"source",
"and",
"finds",
"and",
"loads",
"a",
"WSGI",
"application",
"defined",
"by",
"the",
"entry",
"with",
"name",
"name",
"per",
"the",
"PasteDeploy",
"configuration",
"format",
"and",
"loading",
"mechanism",
"."
] | train | https://github.com/Pylons/plaster_pastedeploy/blob/72a08f3fb6d11a0b039f381ade83f045668cfcb0/src/plaster_pastedeploy/__init__.py#L109-L130 |
Pylons/plaster_pastedeploy | src/plaster_pastedeploy/__init__.py | Loader.get_wsgi_server | def get_wsgi_server(self, name=None, defaults=None):
"""
Reads the configuration source and finds and loads a WSGI server
defined by the server entry with the name ``name`` per the PasteDeploy
configuration format and loading mechanism.
:param name: The named WSGI server to find... | python | def get_wsgi_server(self, name=None, defaults=None):
"""
Reads the configuration source and finds and loads a WSGI server
defined by the server entry with the name ``name`` per the PasteDeploy
configuration format and loading mechanism.
:param name: The named WSGI server to find... | [
"def",
"get_wsgi_server",
"(",
"self",
",",
"name",
"=",
"None",
",",
"defaults",
"=",
"None",
")",
":",
"name",
"=",
"self",
".",
"_maybe_get_default_name",
"(",
"name",
")",
"defaults",
"=",
"self",
".",
"_get_defaults",
"(",
"defaults",
")",
"return",
... | Reads the configuration source and finds and loads a WSGI server
defined by the server entry with the name ``name`` per the PasteDeploy
configuration format and loading mechanism.
:param name: The named WSGI server to find, load and return. Defaults
to ``None`` which becomes ``main`... | [
"Reads",
"the",
"configuration",
"source",
"and",
"finds",
"and",
"loads",
"a",
"WSGI",
"server",
"defined",
"by",
"the",
"server",
"entry",
"with",
"the",
"name",
"name",
"per",
"the",
"PasteDeploy",
"configuration",
"format",
"and",
"loading",
"mechanism",
"... | train | https://github.com/Pylons/plaster_pastedeploy/blob/72a08f3fb6d11a0b039f381ade83f045668cfcb0/src/plaster_pastedeploy/__init__.py#L132-L153 |
Pylons/plaster_pastedeploy | src/plaster_pastedeploy/__init__.py | Loader.get_wsgi_filter | def get_wsgi_filter(self, name=None, defaults=None):
"""Reads the configuration soruce and finds and loads a WSGI filter
defined by the filter entry with the name ``name`` per the PasteDeploy
configuration format and loading mechanism.
:param name: The named WSGI filter to find, load an... | python | def get_wsgi_filter(self, name=None, defaults=None):
"""Reads the configuration soruce and finds and loads a WSGI filter
defined by the filter entry with the name ``name`` per the PasteDeploy
configuration format and loading mechanism.
:param name: The named WSGI filter to find, load an... | [
"def",
"get_wsgi_filter",
"(",
"self",
",",
"name",
"=",
"None",
",",
"defaults",
"=",
"None",
")",
":",
"name",
"=",
"self",
".",
"_maybe_get_default_name",
"(",
"name",
")",
"defaults",
"=",
"self",
".",
"_get_defaults",
"(",
"defaults",
")",
"return",
... | Reads the configuration soruce and finds and loads a WSGI filter
defined by the filter entry with the name ``name`` per the PasteDeploy
configuration format and loading mechanism.
:param name: The named WSGI filter to find, load and return. Defaults
to ``None`` which becomes ``main`... | [
"Reads",
"the",
"configuration",
"soruce",
"and",
"finds",
"and",
"loads",
"a",
"WSGI",
"filter",
"defined",
"by",
"the",
"filter",
"entry",
"with",
"the",
"name",
"name",
"per",
"the",
"PasteDeploy",
"configuration",
"format",
"and",
"loading",
"mechanism",
"... | train | https://github.com/Pylons/plaster_pastedeploy/blob/72a08f3fb6d11a0b039f381ade83f045668cfcb0/src/plaster_pastedeploy/__init__.py#L155-L174 |
Pylons/plaster_pastedeploy | src/plaster_pastedeploy/__init__.py | Loader.get_wsgi_app_settings | def get_wsgi_app_settings(self, name=None, defaults=None):
"""
Return an :class:`collections.OrderedDict` representing the
application config for a WSGI application named ``name`` in the
PasteDeploy config file specified by ``self.uri``.
``defaults``, if passed, should be a dict... | python | def get_wsgi_app_settings(self, name=None, defaults=None):
"""
Return an :class:`collections.OrderedDict` representing the
application config for a WSGI application named ``name`` in the
PasteDeploy config file specified by ``self.uri``.
``defaults``, if passed, should be a dict... | [
"def",
"get_wsgi_app_settings",
"(",
"self",
",",
"name",
"=",
"None",
",",
"defaults",
"=",
"None",
")",
":",
"name",
"=",
"self",
".",
"_maybe_get_default_name",
"(",
"name",
")",
"defaults",
"=",
"self",
".",
"_get_defaults",
"(",
"defaults",
")",
"conf... | Return an :class:`collections.OrderedDict` representing the
application config for a WSGI application named ``name`` in the
PasteDeploy config file specified by ``self.uri``.
``defaults``, if passed, should be a dictionary used as variable
assignments like ``{'http_port': 8080}``. This... | [
"Return",
"an",
":",
"class",
":",
"collections",
".",
"OrderedDict",
"representing",
"the",
"application",
"config",
"for",
"a",
"WSGI",
"application",
"named",
"name",
"in",
"the",
"PasteDeploy",
"config",
"file",
"specified",
"by",
"self",
".",
"uri",
"."
] | train | https://github.com/Pylons/plaster_pastedeploy/blob/72a08f3fb6d11a0b039f381ade83f045668cfcb0/src/plaster_pastedeploy/__init__.py#L176-L206 |
Pylons/plaster_pastedeploy | src/plaster_pastedeploy/__init__.py | Loader.setup_logging | def setup_logging(self, defaults=None):
"""
Set up logging via :func:`logging.config.fileConfig`.
Defaults are specified for the special ``__file__`` and ``here``
variables, similar to PasteDeploy config loading. Extra defaults can
optionally be specified as a dict in ``defaults... | python | def setup_logging(self, defaults=None):
"""
Set up logging via :func:`logging.config.fileConfig`.
Defaults are specified for the special ``__file__`` and ``here``
variables, similar to PasteDeploy config loading. Extra defaults can
optionally be specified as a dict in ``defaults... | [
"def",
"setup_logging",
"(",
"self",
",",
"defaults",
"=",
"None",
")",
":",
"if",
"\"loggers\"",
"in",
"self",
".",
"get_sections",
"(",
")",
":",
"defaults",
"=",
"self",
".",
"_get_defaults",
"(",
"defaults",
")",
"fileConfig",
"(",
"self",
".",
"uri"... | Set up logging via :func:`logging.config.fileConfig`.
Defaults are specified for the special ``__file__`` and ``here``
variables, similar to PasteDeploy config loading. Extra defaults can
optionally be specified as a dict in ``defaults``.
:param defaults: The defaults that will be used... | [
"Set",
"up",
"logging",
"via",
":",
"func",
":",
"logging",
".",
"config",
".",
"fileConfig",
"."
] | train | https://github.com/Pylons/plaster_pastedeploy/blob/72a08f3fb6d11a0b039f381ade83f045668cfcb0/src/plaster_pastedeploy/__init__.py#L208-L226 |
Pylons/plaster_pastedeploy | src/plaster_pastedeploy/__init__.py | Loader._maybe_get_default_name | def _maybe_get_default_name(self, name):
"""Checks a name and determines whether to use the default name.
:param name: The current name to check.
:return: Either None or a :class:`str` representing the name.
"""
if name is None and self.uri.fragment:
name = self.uri.... | python | def _maybe_get_default_name(self, name):
"""Checks a name and determines whether to use the default name.
:param name: The current name to check.
:return: Either None or a :class:`str` representing the name.
"""
if name is None and self.uri.fragment:
name = self.uri.... | [
"def",
"_maybe_get_default_name",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"is",
"None",
"and",
"self",
".",
"uri",
".",
"fragment",
":",
"name",
"=",
"self",
".",
"uri",
".",
"fragment",
"return",
"name"
] | Checks a name and determines whether to use the default name.
:param name: The current name to check.
:return: Either None or a :class:`str` representing the name. | [
"Checks",
"a",
"name",
"and",
"determines",
"whether",
"to",
"use",
"the",
"default",
"name",
"."
] | train | https://github.com/Pylons/plaster_pastedeploy/blob/72a08f3fb6d11a0b039f381ade83f045668cfcb0/src/plaster_pastedeploy/__init__.py#L245-L253 |
j4321/tkColorPicker | tkcolorpicker/gradientbar.py | GradientBar.set | def set(self, hue):
"""Set cursor position on the color corresponding to the hue value."""
x = hue / 360. * self.winfo_width()
self.coords('cursor', x, 0, x, self.winfo_height())
self._variable.set(hue) | python | def set(self, hue):
"""Set cursor position on the color corresponding to the hue value."""
x = hue / 360. * self.winfo_width()
self.coords('cursor', x, 0, x, self.winfo_height())
self._variable.set(hue) | [
"def",
"set",
"(",
"self",
",",
"hue",
")",
":",
"x",
"=",
"hue",
"/",
"360.",
"*",
"self",
".",
"winfo_width",
"(",
")",
"self",
".",
"coords",
"(",
"'cursor'",
",",
"x",
",",
"0",
",",
"x",
",",
"self",
".",
"winfo_height",
"(",
")",
")",
"... | Set cursor position on the color corresponding to the hue value. | [
"Set",
"cursor",
"position",
"on",
"the",
"color",
"corresponding",
"to",
"the",
"hue",
"value",
"."
] | train | https://github.com/j4321/tkColorPicker/blob/ee2d583115e0c7ad7f29795763fc6b4ddc4e8c1d/tkcolorpicker/gradientbar.py#L115-L119 |
twisted/axiom | twisted/plugins/axiom_plugins.py | AxiomaticStart.makeService | def makeService(cls, options):
"""
Create an L{IService} for the database specified by the given
configuration.
"""
from axiom.store import Store
jm = options['journal-mode']
if jm is not None:
jm = jm.decode('ascii')
store = Store(options['dbd... | python | def makeService(cls, options):
"""
Create an L{IService} for the database specified by the given
configuration.
"""
from axiom.store import Store
jm = options['journal-mode']
if jm is not None:
jm = jm.decode('ascii')
store = Store(options['dbd... | [
"def",
"makeService",
"(",
"cls",
",",
"options",
")",
":",
"from",
"axiom",
".",
"store",
"import",
"Store",
"jm",
"=",
"options",
"[",
"'journal-mode'",
"]",
"if",
"jm",
"is",
"not",
"None",
":",
"jm",
"=",
"jm",
".",
"decode",
"(",
"'ascii'",
")",... | Create an L{IService} for the database specified by the given
configuration. | [
"Create",
"an",
"L",
"{",
"IService",
"}",
"for",
"the",
"database",
"specified",
"by",
"the",
"given",
"configuration",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/twisted/plugins/axiom_plugins.py#L49-L61 |
swharden/PyOriginTools | PyOriginTools/highlevel.py | pageNames | def pageNames(matching=False,workbooks=True,graphs=True):
"""
Returns the names of everything (books, notes, graphs, etc.) in the project.
Args:
matching (str, optional): if given, only return names with this string in it
workbooks (bool): if True, return workbooks
graphs (bool): if... | python | def pageNames(matching=False,workbooks=True,graphs=True):
"""
Returns the names of everything (books, notes, graphs, etc.) in the project.
Args:
matching (str, optional): if given, only return names with this string in it
workbooks (bool): if True, return workbooks
graphs (bool): if... | [
"def",
"pageNames",
"(",
"matching",
"=",
"False",
",",
"workbooks",
"=",
"True",
",",
"graphs",
"=",
"True",
")",
":",
"# first collect the pages we want",
"pages",
"=",
"[",
"]",
"if",
"workbooks",
":",
"pages",
".",
"extend",
"(",
"PyOrigin",
".",
"Work... | Returns the names of everything (books, notes, graphs, etc.) in the project.
Args:
matching (str, optional): if given, only return names with this string in it
workbooks (bool): if True, return workbooks
graphs (bool): if True, return workbooks
Returns:
A list of the names of w... | [
"Returns",
"the",
"names",
"of",
"everything",
"(",
"books",
"notes",
"graphs",
"etc",
".",
")",
"in",
"the",
"project",
"."
] | train | https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/highlevel.py#L24-L49 |
swharden/PyOriginTools | PyOriginTools/highlevel.py | getPageType | def getPageType(name,number=False):
"""Returns the type of the page with that name.
If that name doesn't exist, None is returned.
Args:
name (str): name of the page to get the folder from
number (bool): if True, return numbers (i.e., a graph will be 3)
if False, return words whe... | python | def getPageType(name,number=False):
"""Returns the type of the page with that name.
If that name doesn't exist, None is returned.
Args:
name (str): name of the page to get the folder from
number (bool): if True, return numbers (i.e., a graph will be 3)
if False, return words whe... | [
"def",
"getPageType",
"(",
"name",
",",
"number",
"=",
"False",
")",
":",
"if",
"not",
"name",
"in",
"pageNames",
"(",
")",
":",
"return",
"None",
"pageType",
"=",
"PyOrigin",
".",
"Pages",
"(",
"name",
")",
".",
"GetType",
"(",
")",
"if",
"number",
... | Returns the type of the page with that name.
If that name doesn't exist, None is returned.
Args:
name (str): name of the page to get the folder from
number (bool): if True, return numbers (i.e., a graph will be 3)
if False, return words where appropriate (i.e, "graph")
Returns:... | [
"Returns",
"the",
"type",
"of",
"the",
"page",
"with",
"that",
"name",
".",
"If",
"that",
"name",
"doesn",
"t",
"exist",
"None",
"is",
"returned",
"."
] | train | https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/highlevel.py#L117-L143 |
swharden/PyOriginTools | PyOriginTools/highlevel.py | listEverything | def listEverything(matching=False):
"""Prints every page in the project to the console.
Args:
matching (str, optional): if given, only return names with this string in it
"""
pages=pageNames()
if matching:
pages=[x for x in pages if matching in x]
for i,page in enumerate(pages)... | python | def listEverything(matching=False):
"""Prints every page in the project to the console.
Args:
matching (str, optional): if given, only return names with this string in it
"""
pages=pageNames()
if matching:
pages=[x for x in pages if matching in x]
for i,page in enumerate(pages)... | [
"def",
"listEverything",
"(",
"matching",
"=",
"False",
")",
":",
"pages",
"=",
"pageNames",
"(",
")",
"if",
"matching",
":",
"pages",
"=",
"[",
"x",
"for",
"x",
"in",
"pages",
"if",
"matching",
"in",
"x",
"]",
"for",
"i",
",",
"page",
"in",
"enume... | Prints every page in the project to the console.
Args:
matching (str, optional): if given, only return names with this string in it | [
"Prints",
"every",
"page",
"in",
"the",
"project",
"to",
"the",
"console",
"."
] | train | https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/highlevel.py#L145-L157 |
swharden/PyOriginTools | PyOriginTools/highlevel.py | sheetNames | def sheetNames(book=None):
"""return sheet names of a book.
Args:
book (str, optional): If a book is given, pull names from
that book. Otherwise, try the active one
Returns:
list of sheet names (typical case).
None if book has no sheets.
False if book doesn't ex... | python | def sheetNames(book=None):
"""return sheet names of a book.
Args:
book (str, optional): If a book is given, pull names from
that book. Otherwise, try the active one
Returns:
list of sheet names (typical case).
None if book has no sheets.
False if book doesn't ex... | [
"def",
"sheetNames",
"(",
"book",
"=",
"None",
")",
":",
"if",
"book",
":",
"if",
"not",
"book",
".",
"lower",
"(",
")",
"in",
"[",
"x",
".",
"lower",
"(",
")",
"for",
"x",
"in",
"bookNames",
"(",
")",
"]",
":",
"return",
"False",
"else",
":",
... | return sheet names of a book.
Args:
book (str, optional): If a book is given, pull names from
that book. Otherwise, try the active one
Returns:
list of sheet names (typical case).
None if book has no sheets.
False if book doesn't exlist. | [
"return",
"sheet",
"names",
"of",
"a",
"book",
"."
] | train | https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/highlevel.py#L202-L225 |
swharden/PyOriginTools | PyOriginTools/highlevel.py | getSheet | def getSheet(book=None,sheet=None):
"""returns the pyorigin object for a sheet."""
# figure out what book to use
if book and not book.lower() in [x.lower() for x in bookNames()]:
print("book %s doesn't exist"%book)
return
if book is None:
book=activeBook().lower()
if book is... | python | def getSheet(book=None,sheet=None):
"""returns the pyorigin object for a sheet."""
# figure out what book to use
if book and not book.lower() in [x.lower() for x in bookNames()]:
print("book %s doesn't exist"%book)
return
if book is None:
book=activeBook().lower()
if book is... | [
"def",
"getSheet",
"(",
"book",
"=",
"None",
",",
"sheet",
"=",
"None",
")",
":",
"# figure out what book to use",
"if",
"book",
"and",
"not",
"book",
".",
"lower",
"(",
")",
"in",
"[",
"x",
".",
"lower",
"(",
")",
"for",
"x",
"in",
"bookNames",
"(",... | returns the pyorigin object for a sheet. | [
"returns",
"the",
"pyorigin",
"object",
"for",
"a",
"sheet",
"."
] | train | https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/highlevel.py#L227-L254 |
swharden/PyOriginTools | PyOriginTools/highlevel.py | sheetDelete | def sheetDelete(book=None,sheet=None):
"""
Delete a sheet from a book. If either isn't given, use the active one.
"""
if book is None:
book=activeBook()
if sheet in sheetNames():
PyOrigin.WorksheetPages(book).Layers(sheetNames().index(sheet)).Destroy() | python | def sheetDelete(book=None,sheet=None):
"""
Delete a sheet from a book. If either isn't given, use the active one.
"""
if book is None:
book=activeBook()
if sheet in sheetNames():
PyOrigin.WorksheetPages(book).Layers(sheetNames().index(sheet)).Destroy() | [
"def",
"sheetDelete",
"(",
"book",
"=",
"None",
",",
"sheet",
"=",
"None",
")",
":",
"if",
"book",
"is",
"None",
":",
"book",
"=",
"activeBook",
"(",
")",
"if",
"sheet",
"in",
"sheetNames",
"(",
")",
":",
"PyOrigin",
".",
"WorksheetPages",
"(",
"book... | Delete a sheet from a book. If either isn't given, use the active one. | [
"Delete",
"a",
"sheet",
"from",
"a",
"book",
".",
"If",
"either",
"isn",
"t",
"given",
"use",
"the",
"active",
"one",
"."
] | train | https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/highlevel.py#L260-L267 |
swharden/PyOriginTools | PyOriginTools/highlevel.py | sheetDeleteEmpty | def sheetDeleteEmpty(bookName=None):
"""Delete all sheets which contain no data"""
if bookName is None:
bookName = activeBook()
if not bookName.lower() in [x.lower() for x in bookNames()]:
print("can't clean up a book that doesn't exist:",bookName)
return
poBook=PyOrigin.Workshee... | python | def sheetDeleteEmpty(bookName=None):
"""Delete all sheets which contain no data"""
if bookName is None:
bookName = activeBook()
if not bookName.lower() in [x.lower() for x in bookNames()]:
print("can't clean up a book that doesn't exist:",bookName)
return
poBook=PyOrigin.Workshee... | [
"def",
"sheetDeleteEmpty",
"(",
"bookName",
"=",
"None",
")",
":",
"if",
"bookName",
"is",
"None",
":",
"bookName",
"=",
"activeBook",
"(",
")",
"if",
"not",
"bookName",
".",
"lower",
"(",
")",
"in",
"[",
"x",
".",
"lower",
"(",
")",
"for",
"x",
"i... | Delete all sheets which contain no data | [
"Delete",
"all",
"sheets",
"which",
"contain",
"no",
"data"
] | train | https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/highlevel.py#L275-L290 |
swharden/PyOriginTools | PyOriginTools/highlevel.py | pickle_load | def pickle_load(fname):
"""return the contents of a pickle file"""
assert type(fname) is str and os.path.exists(fname)
print("loaded",fname)
return pickle.load(open(fname,"rb")) | python | def pickle_load(fname):
"""return the contents of a pickle file"""
assert type(fname) is str and os.path.exists(fname)
print("loaded",fname)
return pickle.load(open(fname,"rb")) | [
"def",
"pickle_load",
"(",
"fname",
")",
":",
"assert",
"type",
"(",
"fname",
")",
"is",
"str",
"and",
"os",
".",
"path",
".",
"exists",
"(",
"fname",
")",
"print",
"(",
"\"loaded\"",
",",
"fname",
")",
"return",
"pickle",
".",
"load",
"(",
"open",
... | return the contents of a pickle file | [
"return",
"the",
"contents",
"of",
"a",
"pickle",
"file"
] | train | https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/highlevel.py#L303-L307 |
swharden/PyOriginTools | PyOriginTools/highlevel.py | pickle_save | def pickle_save(thing,fname=None):
"""save something to a pickle file"""
if fname is None:
fname=os.path.expanduser("~")+"/%d.pkl"%time.time()
assert type(fname) is str and os.path.isdir(os.path.dirname(fname))
pickle.dump(thing, open(fname,"wb"),pickle.HIGHEST_PROTOCOL)
print("saved",fname) | python | def pickle_save(thing,fname=None):
"""save something to a pickle file"""
if fname is None:
fname=os.path.expanduser("~")+"/%d.pkl"%time.time()
assert type(fname) is str and os.path.isdir(os.path.dirname(fname))
pickle.dump(thing, open(fname,"wb"),pickle.HIGHEST_PROTOCOL)
print("saved",fname) | [
"def",
"pickle_save",
"(",
"thing",
",",
"fname",
"=",
"None",
")",
":",
"if",
"fname",
"is",
"None",
":",
"fname",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~\"",
")",
"+",
"\"/%d.pkl\"",
"%",
"time",
".",
"time",
"(",
")",
"assert",
"typ... | save something to a pickle file | [
"save",
"something",
"to",
"a",
"pickle",
"file"
] | train | https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/highlevel.py#L309-L315 |
swharden/PyOriginTools | PyOriginTools/highlevel.py | sheetToHTML | def sheetToHTML(sheet):
"""
Put 2d numpy data into a temporary HTML file.
This is a hack, copy/pasted from an earlier version of this software.
It is very messy, but works great! Good enough for me.
"""
assert "SHEET" in str(type(sheet))
#data,names=None,units=None,bookName=None,sheetName=N... | python | def sheetToHTML(sheet):
"""
Put 2d numpy data into a temporary HTML file.
This is a hack, copy/pasted from an earlier version of this software.
It is very messy, but works great! Good enough for me.
"""
assert "SHEET" in str(type(sheet))
#data,names=None,units=None,bookName=None,sheetName=N... | [
"def",
"sheetToHTML",
"(",
"sheet",
")",
":",
"assert",
"\"SHEET\"",
"in",
"str",
"(",
"type",
"(",
"sheet",
")",
")",
"#data,names=None,units=None,bookName=None,sheetName=None,xCol=None",
"#sheet=OR.SHEET()",
"data",
"=",
"sheet",
".",
"data",
"names",
"=",
"sheet"... | Put 2d numpy data into a temporary HTML file.
This is a hack, copy/pasted from an earlier version of this software.
It is very messy, but works great! Good enough for me. | [
"Put",
"2d",
"numpy",
"data",
"into",
"a",
"temporary",
"HTML",
"file",
".",
"This",
"is",
"a",
"hack",
"copy",
"/",
"pasted",
"from",
"an",
"earlier",
"version",
"of",
"this",
"software",
".",
"It",
"is",
"very",
"messy",
"but",
"works",
"great!",
"Go... | train | https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/highlevel.py#L318-L405 |
swharden/PyOriginTools | documentation/PyOrigin-examples/convert_html.py | getCodeBlocks | def getCodeBlocks():
"""return a dict with the code for each function"""
raw=open("examples.py").read()
d={}
for block in raw.split("if __name__")[0].split("\ndef "):
title=block.split("\n")[0].split("(")[0]
if not title.startswith("demo_"):
continue
code=[x[4:] for x... | python | def getCodeBlocks():
"""return a dict with the code for each function"""
raw=open("examples.py").read()
d={}
for block in raw.split("if __name__")[0].split("\ndef "):
title=block.split("\n")[0].split("(")[0]
if not title.startswith("demo_"):
continue
code=[x[4:] for x... | [
"def",
"getCodeBlocks",
"(",
")",
":",
"raw",
"=",
"open",
"(",
"\"examples.py\"",
")",
".",
"read",
"(",
")",
"d",
"=",
"{",
"}",
"for",
"block",
"in",
"raw",
".",
"split",
"(",
"\"if __name__\"",
")",
"[",
"0",
"]",
".",
"split",
"(",
"\"\\ndef \... | return a dict with the code for each function | [
"return",
"a",
"dict",
"with",
"the",
"code",
"for",
"each",
"function"
] | train | https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/documentation/PyOrigin-examples/convert_html.py#L15-L25 |
swharden/PyOriginTools | documentation/PyOrigin-examples/convert_html.py | getOutputBlocks | def getOutputBlocks():
"""return a dict with the output of each function"""
raw=open("output.txt").read()
d={}
for block in raw.split("\n####### ")[1:]:
title=block.split("\n")[0].split("(")[0]
block=block.split("\n",1)[1].strip()
d[title]=block.split("\nfinished in ")[0]
ret... | python | def getOutputBlocks():
"""return a dict with the output of each function"""
raw=open("output.txt").read()
d={}
for block in raw.split("\n####### ")[1:]:
title=block.split("\n")[0].split("(")[0]
block=block.split("\n",1)[1].strip()
d[title]=block.split("\nfinished in ")[0]
ret... | [
"def",
"getOutputBlocks",
"(",
")",
":",
"raw",
"=",
"open",
"(",
"\"output.txt\"",
")",
".",
"read",
"(",
")",
"d",
"=",
"{",
"}",
"for",
"block",
"in",
"raw",
".",
"split",
"(",
"\"\\n####### \"",
")",
"[",
"1",
":",
"]",
":",
"title",
"=",
"bl... | return a dict with the output of each function | [
"return",
"a",
"dict",
"with",
"the",
"output",
"of",
"each",
"function"
] | train | https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/documentation/PyOrigin-examples/convert_html.py#L27-L35 |
twisted/axiom | axiom/scripts/axiomatic.py | AxiomaticSubCommandMixin.decodeCommandLine | def decodeCommandLine(self, cmdline):
"""Turn a byte string from the command line into a unicode string.
"""
codec = getattr(sys.stdin, 'encoding', None) or sys.getdefaultencoding()
return unicode(cmdline, codec) | python | def decodeCommandLine(self, cmdline):
"""Turn a byte string from the command line into a unicode string.
"""
codec = getattr(sys.stdin, 'encoding', None) or sys.getdefaultencoding()
return unicode(cmdline, codec) | [
"def",
"decodeCommandLine",
"(",
"self",
",",
"cmdline",
")",
":",
"codec",
"=",
"getattr",
"(",
"sys",
".",
"stdin",
",",
"'encoding'",
",",
"None",
")",
"or",
"sys",
".",
"getdefaultencoding",
"(",
")",
"return",
"unicode",
"(",
"cmdline",
",",
"codec"... | Turn a byte string from the command line into a unicode string. | [
"Turn",
"a",
"byte",
"string",
"from",
"the",
"command",
"line",
"into",
"a",
"unicode",
"string",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/scripts/axiomatic.py#L20-L24 |
davidmcclure/textplot | textplot/utils.py | tokenize | def tokenize(text):
"""
Yield tokens.
Args:
text (str): The original text.
Yields:
dict: The next token.
"""
stem = PorterStemmer().stem
tokens = re.finditer('[a-z]+', text.lower())
for offset, match in enumerate(tokens):
# Get the raw token.
unstemm... | python | def tokenize(text):
"""
Yield tokens.
Args:
text (str): The original text.
Yields:
dict: The next token.
"""
stem = PorterStemmer().stem
tokens = re.finditer('[a-z]+', text.lower())
for offset, match in enumerate(tokens):
# Get the raw token.
unstemm... | [
"def",
"tokenize",
"(",
"text",
")",
":",
"stem",
"=",
"PorterStemmer",
"(",
")",
".",
"stem",
"tokens",
"=",
"re",
".",
"finditer",
"(",
"'[a-z]+'",
",",
"text",
".",
"lower",
"(",
")",
")",
"for",
"offset",
",",
"match",
"in",
"enumerate",
"(",
"... | Yield tokens.
Args:
text (str): The original text.
Yields:
dict: The next token. | [
"Yield",
"tokens",
"."
] | train | https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/utils.py#L12-L36 |
davidmcclure/textplot | textplot/utils.py | sort_dict | def sort_dict(d, desc=True):
"""
Sort an ordered dictionary by value, descending.
Args:
d (OrderedDict): An ordered dictionary.
desc (bool): If true, sort desc.
Returns:
OrderedDict: The sorted dictionary.
"""
sort = sorted(d.items(), key=lambda x: x[1], reverse=desc)... | python | def sort_dict(d, desc=True):
"""
Sort an ordered dictionary by value, descending.
Args:
d (OrderedDict): An ordered dictionary.
desc (bool): If true, sort desc.
Returns:
OrderedDict: The sorted dictionary.
"""
sort = sorted(d.items(), key=lambda x: x[1], reverse=desc)... | [
"def",
"sort_dict",
"(",
"d",
",",
"desc",
"=",
"True",
")",
":",
"sort",
"=",
"sorted",
"(",
"d",
".",
"items",
"(",
")",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
"[",
"1",
"]",
",",
"reverse",
"=",
"desc",
")",
"return",
"OrderedDict",
"(",
... | Sort an ordered dictionary by value, descending.
Args:
d (OrderedDict): An ordered dictionary.
desc (bool): If true, sort desc.
Returns:
OrderedDict: The sorted dictionary. | [
"Sort",
"an",
"ordered",
"dictionary",
"by",
"value",
"descending",
"."
] | train | https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/utils.py#L39-L53 |
davidmcclure/textplot | textplot/utils.py | window | def window(seq, n=2):
"""
Yield a sliding window over an iterable.
Args:
seq (iter): The sequence.
n (int): The window width.
Yields:
tuple: The next window.
"""
it = iter(seq)
result = tuple(islice(it, n))
if len(result) == n:
yield result
for t... | python | def window(seq, n=2):
"""
Yield a sliding window over an iterable.
Args:
seq (iter): The sequence.
n (int): The window width.
Yields:
tuple: The next window.
"""
it = iter(seq)
result = tuple(islice(it, n))
if len(result) == n:
yield result
for t... | [
"def",
"window",
"(",
"seq",
",",
"n",
"=",
"2",
")",
":",
"it",
"=",
"iter",
"(",
"seq",
")",
"result",
"=",
"tuple",
"(",
"islice",
"(",
"it",
",",
"n",
")",
")",
"if",
"len",
"(",
"result",
")",
"==",
"n",
":",
"yield",
"result",
"for",
... | Yield a sliding window over an iterable.
Args:
seq (iter): The sequence.
n (int): The window width.
Yields:
tuple: The next window. | [
"Yield",
"a",
"sliding",
"window",
"over",
"an",
"iterable",
"."
] | train | https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/utils.py#L56-L77 |
twisted/axiom | axiom/userbase.py | insertUserStore | def insertUserStore(siteStore, userStorePath):
"""
Move the SubStore at the indicated location into the given site store's
directory and then hook it up to the site store's authentication database.
@type siteStore: C{Store}
@type userStorePath: C{FilePath}
"""
# The following may, but does ... | python | def insertUserStore(siteStore, userStorePath):
"""
Move the SubStore at the indicated location into the given site store's
directory and then hook it up to the site store's authentication database.
@type siteStore: C{Store}
@type userStorePath: C{FilePath}
"""
# The following may, but does ... | [
"def",
"insertUserStore",
"(",
"siteStore",
",",
"userStorePath",
")",
":",
"# The following may, but does not need to be in a transaction, because it",
"# is merely an attempt to guess a reasonable filesystem name to use for",
"# this avatar. The user store being operated on is expected to be ... | Move the SubStore at the indicated location into the given site store's
directory and then hook it up to the site store's authentication database.
@type siteStore: C{Store}
@type userStorePath: C{FilePath} | [
"Move",
"the",
"SubStore",
"at",
"the",
"indicated",
"location",
"into",
"the",
"given",
"site",
"store",
"s",
"directory",
"and",
"then",
"hook",
"it",
"up",
"to",
"the",
"site",
"store",
"s",
"authentication",
"database",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L306-L342 |
twisted/axiom | axiom/userbase.py | extractUserStore | def extractUserStore(userAccount, extractionDestination, legacySiteAuthoritative=True):
"""
Move the SubStore for the given user account out of the given site store
completely. Place the user store's database directory into the given
destination directory.
@type userAccount: C{LoginAccount}
@t... | python | def extractUserStore(userAccount, extractionDestination, legacySiteAuthoritative=True):
"""
Move the SubStore for the given user account out of the given site store
completely. Place the user store's database directory into the given
destination directory.
@type userAccount: C{LoginAccount}
@t... | [
"def",
"extractUserStore",
"(",
"userAccount",
",",
"extractionDestination",
",",
"legacySiteAuthoritative",
"=",
"True",
")",
":",
"if",
"legacySiteAuthoritative",
":",
"# migrateDown() manages its own transactions, since it is copying items",
"# between two different stores.",
"u... | Move the SubStore for the given user account out of the given site store
completely. Place the user store's database directory into the given
destination directory.
@type userAccount: C{LoginAccount}
@type extractionDestination: C{FilePath}
@type legacySiteAuthoritative: C{bool}
@param legac... | [
"Move",
"the",
"SubStore",
"for",
"the",
"given",
"user",
"account",
"out",
"of",
"the",
"given",
"site",
"store",
"completely",
".",
"Place",
"the",
"user",
"store",
"s",
"database",
"directory",
"into",
"the",
"given",
"destination",
"directory",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L345-L397 |
twisted/axiom | axiom/userbase.py | getLoginMethods | def getLoginMethods(store, protocol=None):
"""
Retrieve L{LoginMethod} items from store C{store}, optionally constraining
them by protocol
"""
if protocol is not None:
comp = OR(LoginMethod.protocol == u'*',
LoginMethod.protocol == protocol)
else:
comp = None
... | python | def getLoginMethods(store, protocol=None):
"""
Retrieve L{LoginMethod} items from store C{store}, optionally constraining
them by protocol
"""
if protocol is not None:
comp = OR(LoginMethod.protocol == u'*',
LoginMethod.protocol == protocol)
else:
comp = None
... | [
"def",
"getLoginMethods",
"(",
"store",
",",
"protocol",
"=",
"None",
")",
":",
"if",
"protocol",
"is",
"not",
"None",
":",
"comp",
"=",
"OR",
"(",
"LoginMethod",
".",
"protocol",
"==",
"u'*'",
",",
"LoginMethod",
".",
"protocol",
"==",
"protocol",
")",
... | Retrieve L{LoginMethod} items from store C{store}, optionally constraining
them by protocol | [
"Retrieve",
"L",
"{",
"LoginMethod",
"}",
"items",
"from",
"store",
"C",
"{",
"store",
"}",
"optionally",
"constraining",
"them",
"by",
"protocol"
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L599-L609 |
twisted/axiom | axiom/userbase.py | getAccountNames | def getAccountNames(store, protocol=None):
"""
Retrieve account name information about the given database.
@param store: An Axiom Store representing a user account. It must
have been opened through the store which contains its account
information.
@return: A generator of two-tuples of (userna... | python | def getAccountNames(store, protocol=None):
"""
Retrieve account name information about the given database.
@param store: An Axiom Store representing a user account. It must
have been opened through the store which contains its account
information.
@return: A generator of two-tuples of (userna... | [
"def",
"getAccountNames",
"(",
"store",
",",
"protocol",
"=",
"None",
")",
":",
"return",
"(",
"(",
"meth",
".",
"localpart",
",",
"meth",
".",
"domain",
")",
"for",
"meth",
"in",
"getLoginMethods",
"(",
"store",
",",
"protocol",
")",
")"
] | Retrieve account name information about the given database.
@param store: An Axiom Store representing a user account. It must
have been opened through the store which contains its account
information.
@return: A generator of two-tuples of (username, domain) which
refer to the given store. | [
"Retrieve",
"account",
"name",
"information",
"about",
"the",
"given",
"database",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L612-L624 |
twisted/axiom | axiom/userbase.py | getDomainNames | def getDomainNames(store):
"""
Retrieve a list of all local domain names represented in the given store.
"""
domains = set()
domains.update(store.query(
LoginMethod,
AND(LoginMethod.internal == True,
LoginMethod.domain != None)).getColumn("domain").distinct())... | python | def getDomainNames(store):
"""
Retrieve a list of all local domain names represented in the given store.
"""
domains = set()
domains.update(store.query(
LoginMethod,
AND(LoginMethod.internal == True,
LoginMethod.domain != None)).getColumn("domain").distinct())... | [
"def",
"getDomainNames",
"(",
"store",
")",
":",
"domains",
"=",
"set",
"(",
")",
"domains",
".",
"update",
"(",
"store",
".",
"query",
"(",
"LoginMethod",
",",
"AND",
"(",
"LoginMethod",
".",
"internal",
"==",
"True",
",",
"LoginMethod",
".",
"domain",
... | Retrieve a list of all local domain names represented in the given store. | [
"Retrieve",
"a",
"list",
"of",
"all",
"local",
"domain",
"names",
"represented",
"in",
"the",
"given",
"store",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L627-L636 |
twisted/axiom | axiom/userbase.py | LoginAccount.migrateDown | def migrateDown(self):
"""
Assuming that self.avatars is a SubStore which should contain *only*
the LoginAccount for the user I represent, remove all LoginAccounts and
LoginMethods from that store and copy all methods from the site store
down into it.
"""
ss = sel... | python | def migrateDown(self):
"""
Assuming that self.avatars is a SubStore which should contain *only*
the LoginAccount for the user I represent, remove all LoginAccounts and
LoginMethods from that store and copy all methods from the site store
down into it.
"""
ss = sel... | [
"def",
"migrateDown",
"(",
"self",
")",
":",
"ss",
"=",
"self",
".",
"avatars",
".",
"open",
"(",
")",
"def",
"_",
"(",
")",
":",
"oldAccounts",
"=",
"ss",
".",
"query",
"(",
"LoginAccount",
")",
"oldMethods",
"=",
"ss",
".",
"query",
"(",
"LoginMe... | Assuming that self.avatars is a SubStore which should contain *only*
the LoginAccount for the user I represent, remove all LoginAccounts and
LoginMethods from that store and copy all methods from the site store
down into it. | [
"Assuming",
"that",
"self",
".",
"avatars",
"is",
"a",
"SubStore",
"which",
"should",
"contain",
"*",
"only",
"*",
"the",
"LoginAccount",
"for",
"the",
"user",
"I",
"represent",
"remove",
"all",
"LoginAccounts",
"and",
"LoginMethods",
"from",
"that",
"store",
... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L189-L204 |
twisted/axiom | axiom/userbase.py | LoginAccount.migrateUp | def migrateUp(self):
"""
Copy this LoginAccount and all associated LoginMethods from my store
(which is assumed to be a SubStore, most likely a user store) into the
site store which contains it.
"""
siteStore = self.store.parent
def _():
# No convenien... | python | def migrateUp(self):
"""
Copy this LoginAccount and all associated LoginMethods from my store
(which is assumed to be a SubStore, most likely a user store) into the
site store which contains it.
"""
siteStore = self.store.parent
def _():
# No convenien... | [
"def",
"migrateUp",
"(",
"self",
")",
":",
"siteStore",
"=",
"self",
".",
"store",
".",
"parent",
"def",
"_",
"(",
")",
":",
"# No convenience method for the following because needing to do it is",
"# *rare*. It *should* be ugly; 99% of the time if you need to do this",
"# y... | Copy this LoginAccount and all associated LoginMethods from my store
(which is assumed to be a SubStore, most likely a user store) into the
site store which contains it. | [
"Copy",
"this",
"LoginAccount",
"and",
"all",
"associated",
"LoginMethods",
"from",
"my",
"store",
"(",
"which",
"is",
"assumed",
"to",
"be",
"a",
"SubStore",
"most",
"likely",
"a",
"user",
"store",
")",
"into",
"the",
"site",
"store",
"which",
"contains",
... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L207-L221 |
twisted/axiom | axiom/userbase.py | LoginAccount.cloneInto | def cloneInto(self, newStore, avatars):
"""
Create a copy of this LoginAccount and all associated LoginMethods in a different Store.
Return the copied LoginAccount.
"""
la = LoginAccount(store=newStore,
password=self.password,
... | python | def cloneInto(self, newStore, avatars):
"""
Create a copy of this LoginAccount and all associated LoginMethods in a different Store.
Return the copied LoginAccount.
"""
la = LoginAccount(store=newStore,
password=self.password,
... | [
"def",
"cloneInto",
"(",
"self",
",",
"newStore",
",",
"avatars",
")",
":",
"la",
"=",
"LoginAccount",
"(",
"store",
"=",
"newStore",
",",
"password",
"=",
"self",
".",
"password",
",",
"avatars",
"=",
"avatars",
",",
"disabled",
"=",
"self",
".",
"dis... | Create a copy of this LoginAccount and all associated LoginMethods in a different Store.
Return the copied LoginAccount. | [
"Create",
"a",
"copy",
"of",
"this",
"LoginAccount",
"and",
"all",
"associated",
"LoginMethods",
"in",
"a",
"different",
"Store",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L224-L243 |
twisted/axiom | axiom/userbase.py | LoginAccount.addLoginMethod | def addLoginMethod(self, localpart, domain, protocol=ANY_PROTOCOL, verified=False, internal=False):
"""
Add a login method to this account, propogating up or down as necessary
to site store or user store to maintain consistency.
"""
# Out takes you west or something
if se... | python | def addLoginMethod(self, localpart, domain, protocol=ANY_PROTOCOL, verified=False, internal=False):
"""
Add a login method to this account, propogating up or down as necessary
to site store or user store to maintain consistency.
"""
# Out takes you west or something
if se... | [
"def",
"addLoginMethod",
"(",
"self",
",",
"localpart",
",",
"domain",
",",
"protocol",
"=",
"ANY_PROTOCOL",
",",
"verified",
"=",
"False",
",",
"internal",
"=",
"False",
")",
":",
"# Out takes you west or something",
"if",
"self",
".",
"store",
".",
"parent",... | Add a login method to this account, propogating up or down as necessary
to site store or user store to maintain consistency. | [
"Add",
"a",
"login",
"method",
"to",
"this",
"account",
"propogating",
"up",
"or",
"down",
"as",
"necessary",
"to",
"site",
"store",
"or",
"user",
"store",
"to",
"maintain",
"consistency",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L250-L275 |
twisted/axiom | axiom/userbase.py | LoginAccount.replacePassword | def replacePassword(self, currentPassword, newPassword):
"""
Set this account's password if the current password matches.
@param currentPassword: The password to match against the current one.
@param newPassword: The new password.
@return: A deferred firing when the password ha... | python | def replacePassword(self, currentPassword, newPassword):
"""
Set this account's password if the current password matches.
@param currentPassword: The password to match against the current one.
@param newPassword: The new password.
@return: A deferred firing when the password ha... | [
"def",
"replacePassword",
"(",
"self",
",",
"currentPassword",
",",
"newPassword",
")",
":",
"if",
"unicode",
"(",
"currentPassword",
")",
"!=",
"self",
".",
"password",
":",
"return",
"fail",
"(",
"BadCredentials",
"(",
")",
")",
"return",
"self",
".",
"s... | Set this account's password if the current password matches.
@param currentPassword: The password to match against the current one.
@param newPassword: The new password.
@return: A deferred firing when the password has been changed.
@raise BadCredentials: If the current password did no... | [
"Set",
"this",
"account",
"s",
"password",
"if",
"the",
"current",
"password",
"matches",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L290-L302 |
twisted/axiom | axiom/userbase.py | LoginBase.addAccount | def addAccount(self, username, domain, password, avatars=None,
protocol=u'email', disabled=0, internal=False,
verified=True):
"""
Create a user account, add it to this LoginBase, and return it.
This method must be called within a transaction in my store.
... | python | def addAccount(self, username, domain, password, avatars=None,
protocol=u'email', disabled=0, internal=False,
verified=True):
"""
Create a user account, add it to this LoginBase, and return it.
This method must be called within a transaction in my store.
... | [
"def",
"addAccount",
"(",
"self",
",",
"username",
",",
"domain",
",",
"password",
",",
"avatars",
"=",
"None",
",",
"protocol",
"=",
"u'email'",
",",
"disabled",
"=",
"0",
",",
"internal",
"=",
"False",
",",
"verified",
"=",
"True",
")",
":",
"# unico... | Create a user account, add it to this LoginBase, and return it.
This method must be called within a transaction in my store.
@param username: the user's name.
@param domain: the domain part of the user's name [XXX TODO: this
really ought to say something about whether it's a Q2Q domai... | [
"Create",
"a",
"user",
"account",
"add",
"it",
"to",
"this",
"LoginBase",
"and",
"return",
"it",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L465-L533 |
twisted/axiom | axiom/_pysqlite2.py | Connection.identifySQLError | def identifySQLError(self, sql, args, e):
"""
Identify an appropriate SQL error object for the given message for the
supported versions of sqlite.
@return: an SQLError
"""
message = e.args[0]
if message.startswith("table") and message.endswith("already exists"):
... | python | def identifySQLError(self, sql, args, e):
"""
Identify an appropriate SQL error object for the given message for the
supported versions of sqlite.
@return: an SQLError
"""
message = e.args[0]
if message.startswith("table") and message.endswith("already exists"):
... | [
"def",
"identifySQLError",
"(",
"self",
",",
"sql",
",",
"args",
",",
"e",
")",
":",
"message",
"=",
"e",
".",
"args",
"[",
"0",
"]",
"if",
"message",
".",
"startswith",
"(",
"\"table\"",
")",
"and",
"message",
".",
"endswith",
"(",
"\"already exists\"... | Identify an appropriate SQL error object for the given message for the
supported versions of sqlite.
@return: an SQLError | [
"Identify",
"an",
"appropriate",
"SQL",
"error",
"object",
"for",
"the",
"given",
"message",
"for",
"the",
"supported",
"versions",
"of",
"sqlite",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/_pysqlite2.py#L52-L62 |
twisted/axiom | axiom/_fincache.py | createCacheRemoveCallback | def createCacheRemoveCallback(cacheRef, key, finalizer):
"""
Construct a callable to be used as a weakref callback for cache entries.
The callable will invoke the provided finalizer, as well as removing the
cache entry if the cache still exists and contains an entry for the given
key.
@type c... | python | def createCacheRemoveCallback(cacheRef, key, finalizer):
"""
Construct a callable to be used as a weakref callback for cache entries.
The callable will invoke the provided finalizer, as well as removing the
cache entry if the cache still exists and contains an entry for the given
key.
@type c... | [
"def",
"createCacheRemoveCallback",
"(",
"cacheRef",
",",
"key",
",",
"finalizer",
")",
":",
"def",
"remove",
"(",
"reference",
")",
":",
"# Weakref callbacks cannot raise exceptions or DOOM ensues",
"try",
":",
"finalizer",
"(",
")",
"except",
":",
"logErrorNoMatterW... | Construct a callable to be used as a weakref callback for cache entries.
The callable will invoke the provided finalizer, as well as removing the
cache entry if the cache still exists and contains an entry for the given
key.
@type cacheRef: L{weakref.ref} to L{FinalizingCache}
@param cacheRef: A ... | [
"Construct",
"a",
"callable",
"to",
"be",
"used",
"as",
"a",
"weakref",
"callback",
"for",
"cache",
"entries",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/_fincache.py#L39-L71 |
twisted/axiom | axiom/_fincache.py | FinalizingCache.cache | def cache(self, key, value):
"""
Add an entry to the cache.
A weakref to the value is stored, rather than a direct reference. The
value must have a C{__finalizer__} method that returns a callable which
will be invoked when the weakref is broken.
@param key: The key iden... | python | def cache(self, key, value):
"""
Add an entry to the cache.
A weakref to the value is stored, rather than a direct reference. The
value must have a C{__finalizer__} method that returns a callable which
will be invoked when the weakref is broken.
@param key: The key iden... | [
"def",
"cache",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"fin",
"=",
"value",
".",
"__finalizer__",
"(",
")",
"try",
":",
"# It's okay if there's already a cache entry for this key as long",
"# as the weakref has already been broken. See the comment in",
"# get() fo... | Add an entry to the cache.
A weakref to the value is stored, rather than a direct reference. The
value must have a C{__finalizer__} method that returns a callable which
will be invoked when the weakref is broken.
@param key: The key identifying the cache entry.
@param value: T... | [
"Add",
"an",
"entry",
"to",
"the",
"cache",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/_fincache.py#L89-L114 |
twisted/axiom | axiom/_fincache.py | FinalizingCache.uncache | def uncache(self, key, value):
"""
Remove a key from the cache.
As a sanity check, if the specified key is present in the cache, it
must have the given value.
@param key: The key to remove.
@param value: The expected value for the key.
"""
try:
... | python | def uncache(self, key, value):
"""
Remove a key from the cache.
As a sanity check, if the specified key is present in the cache, it
must have the given value.
@param key: The key to remove.
@param value: The expected value for the key.
"""
try:
... | [
"def",
"uncache",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"try",
":",
"assert",
"self",
".",
"get",
"(",
"key",
")",
"is",
"value",
"del",
"self",
".",
"data",
"[",
"key",
"]",
"except",
"KeyError",
":",
"# If the entry has already been removed ... | Remove a key from the cache.
As a sanity check, if the specified key is present in the cache, it
must have the given value.
@param key: The key to remove.
@param value: The expected value for the key. | [
"Remove",
"a",
"key",
"from",
"the",
"cache",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/_fincache.py#L117-L137 |
twisted/axiom | axiom/_fincache.py | FinalizingCache.get | def get(self, key):
"""
Get an entry from the cache by key.
@raise KeyError: if the given key is not present in the cache.
@raise CacheFault: (a L{KeyError} subclass) if the given key is present
in the cache, but the value it points to is gone.
"""
o = self.... | python | def get(self, key):
"""
Get an entry from the cache by key.
@raise KeyError: if the given key is not present in the cache.
@raise CacheFault: (a L{KeyError} subclass) if the given key is present
in the cache, but the value it points to is gone.
"""
o = self.... | [
"def",
"get",
"(",
"self",
",",
"key",
")",
":",
"o",
"=",
"self",
".",
"data",
"[",
"key",
"]",
"(",
")",
"if",
"o",
"is",
"None",
":",
"# On CPython, the weakref callback will always(?) run before any",
"# other code has a chance to observe that the weakref is broke... | Get an entry from the cache by key.
@raise KeyError: if the given key is not present in the cache.
@raise CacheFault: (a L{KeyError} subclass) if the given key is present
in the cache, but the value it points to is gone. | [
"Get",
"an",
"entry",
"from",
"the",
"cache",
"by",
"key",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/_fincache.py#L140-L163 |
ubc/ubcpi | ubcpi/serialize.py | parse_question_xml | def parse_question_xml(root):
"""
Parse <question> element in the UBCPI XBlock's content XML.
Args:
root (lxml.etree.Element): The root of the <question> node in the tree.
Returns:
dict, a deserialized representation of a question. E.g.
{
'text': 'What is the answer... | python | def parse_question_xml(root):
"""
Parse <question> element in the UBCPI XBlock's content XML.
Args:
root (lxml.etree.Element): The root of the <question> node in the tree.
Returns:
dict, a deserialized representation of a question. E.g.
{
'text': 'What is the answer... | [
"def",
"parse_question_xml",
"(",
"root",
")",
":",
"question_dict",
"=",
"dict",
"(",
")",
"question_prompt_el",
"=",
"root",
".",
"find",
"(",
"'text'",
")",
"if",
"question_prompt_el",
"is",
"not",
"None",
":",
"question_dict",
"[",
"'text'",
"]",
"=",
... | Parse <question> element in the UBCPI XBlock's content XML.
Args:
root (lxml.etree.Element): The root of the <question> node in the tree.
Returns:
dict, a deserialized representation of a question. E.g.
{
'text': 'What is the answer to life, the universe and everything?',
... | [
"Parse",
"<question",
">",
"element",
"in",
"the",
"UBCPI",
"XBlock",
"s",
"content",
"XML",
"."
] | train | https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/serialize.py#L67-L98 |
ubc/ubcpi | ubcpi/serialize.py | parse_options_xml | def parse_options_xml(root):
"""
Parse <options> element in the UBCPI XBlock's content XML.
Args:
root (lxml.etree.Element): The root of the <options> node in the tree.
Returns:
a list of deserialized representation of options. E.g.
[{
'text': 'Option 1',
... | python | def parse_options_xml(root):
"""
Parse <options> element in the UBCPI XBlock's content XML.
Args:
root (lxml.etree.Element): The root of the <options> node in the tree.
Returns:
a list of deserialized representation of options. E.g.
[{
'text': 'Option 1',
... | [
"def",
"parse_options_xml",
"(",
"root",
")",
":",
"options",
"=",
"[",
"]",
"correct_option",
"=",
"None",
"rationale",
"=",
"None",
"for",
"option_el",
"in",
"root",
".",
"findall",
"(",
"'option'",
")",
":",
"option_dict",
"=",
"dict",
"(",
")",
"opti... | Parse <options> element in the UBCPI XBlock's content XML.
Args:
root (lxml.etree.Element): The root of the <options> node in the tree.
Returns:
a list of deserialized representation of options. E.g.
[{
'text': 'Option 1',
'image_url': '',
'image_pos... | [
"Parse",
"<options",
">",
"element",
"in",
"the",
"UBCPI",
"XBlock",
"s",
"content",
"XML",
"."
] | train | https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/serialize.py#L101-L154 |
ubc/ubcpi | ubcpi/serialize.py | parse_seeds_xml | def parse_seeds_xml(root):
"""
Parse <seeds> element in the UBCPI XBlock's content XML.
Args:
root (lxml.etree.Element): The root of the <seeds> node in the tree.
Returns:
a list of deserialized representation of seeds. E.g.
[{
'answer': 1, # option index starting ... | python | def parse_seeds_xml(root):
"""
Parse <seeds> element in the UBCPI XBlock's content XML.
Args:
root (lxml.etree.Element): The root of the <seeds> node in the tree.
Returns:
a list of deserialized representation of seeds. E.g.
[{
'answer': 1, # option index starting ... | [
"def",
"parse_seeds_xml",
"(",
"root",
")",
":",
"seeds",
"=",
"[",
"]",
"for",
"seed_el",
"in",
"root",
".",
"findall",
"(",
"'seed'",
")",
":",
"seed_dict",
"=",
"dict",
"(",
")",
"seed_dict",
"[",
"'rationale'",
"]",
"=",
"_safe_get_text",
"(",
"see... | Parse <seeds> element in the UBCPI XBlock's content XML.
Args:
root (lxml.etree.Element): The root of the <seeds> node in the tree.
Returns:
a list of deserialized representation of seeds. E.g.
[{
'answer': 1, # option index starting from one
'rationale': 'This... | [
"Parse",
"<seeds",
">",
"element",
"in",
"the",
"UBCPI",
"XBlock",
"s",
"content",
"XML",
"."
] | train | https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/serialize.py#L157-L189 |
ubc/ubcpi | ubcpi/serialize.py | parse_from_xml | def parse_from_xml(root):
"""
Update the UBCPI XBlock's content from an XML definition.
We need to be strict about the XML we accept, to avoid setting
the XBlock to an invalid state (which will then be persisted).
Args:
root (lxml.etree.Element): The XML definition of the XBlock's content.... | python | def parse_from_xml(root):
"""
Update the UBCPI XBlock's content from an XML definition.
We need to be strict about the XML we accept, to avoid setting
the XBlock to an invalid state (which will then be persisted).
Args:
root (lxml.etree.Element): The XML definition of the XBlock's content.... | [
"def",
"parse_from_xml",
"(",
"root",
")",
":",
"# Check that the root has the correct tag",
"if",
"root",
".",
"tag",
"!=",
"'ubcpi'",
":",
"raise",
"UpdateFromXmlError",
"(",
"_",
"(",
"'Every peer instruction tool must contain an \"ubcpi\" element.'",
")",
")",
"displa... | Update the UBCPI XBlock's content from an XML definition.
We need to be strict about the XML we accept, to avoid setting
the XBlock to an invalid state (which will then be persisted).
Args:
root (lxml.etree.Element): The XML definition of the XBlock's content.
Returns:
A dictionary of... | [
"Update",
"the",
"UBCPI",
"XBlock",
"s",
"content",
"from",
"an",
"XML",
"definition",
"."
] | train | https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/serialize.py#L192-L252 |
ubc/ubcpi | ubcpi/serialize.py | serialize_options | def serialize_options(options, block):
"""
Serialize the options in peer instruction XBlock to xml
Args:
options (lxml.etree.Element): The <options> XML element.
block (PeerInstructionXBlock): The XBlock with configuration to serialize.
Returns:
None
"""
for index, opti... | python | def serialize_options(options, block):
"""
Serialize the options in peer instruction XBlock to xml
Args:
options (lxml.etree.Element): The <options> XML element.
block (PeerInstructionXBlock): The XBlock with configuration to serialize.
Returns:
None
"""
for index, opti... | [
"def",
"serialize_options",
"(",
"options",
",",
"block",
")",
":",
"for",
"index",
",",
"option_dict",
"in",
"enumerate",
"(",
"block",
".",
"options",
")",
":",
"option",
"=",
"etree",
".",
"SubElement",
"(",
"options",
",",
"'option'",
")",
"# set corre... | Serialize the options in peer instruction XBlock to xml
Args:
options (lxml.etree.Element): The <options> XML element.
block (PeerInstructionXBlock): The XBlock with configuration to serialize.
Returns:
None | [
"Serialize",
"the",
"options",
"in",
"peer",
"instruction",
"XBlock",
"to",
"xml"
] | train | https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/serialize.py#L255-L279 |
ubc/ubcpi | ubcpi/serialize.py | serialize_seeds | def serialize_seeds(seeds, block):
"""
Serialize the seeds in peer instruction XBlock to xml
Args:
seeds (lxml.etree.Element): The <seeds> XML element.
block (PeerInstructionXBlock): The XBlock with configuration to serialize.
Returns:
None
"""
for seed_dict in block.se... | python | def serialize_seeds(seeds, block):
"""
Serialize the seeds in peer instruction XBlock to xml
Args:
seeds (lxml.etree.Element): The <seeds> XML element.
block (PeerInstructionXBlock): The XBlock with configuration to serialize.
Returns:
None
"""
for seed_dict in block.se... | [
"def",
"serialize_seeds",
"(",
"seeds",
",",
"block",
")",
":",
"for",
"seed_dict",
"in",
"block",
".",
"seeds",
":",
"seed",
"=",
"etree",
".",
"SubElement",
"(",
"seeds",
",",
"'seed'",
")",
"# options in xml starts with 1",
"seed",
".",
"set",
"(",
"'op... | Serialize the seeds in peer instruction XBlock to xml
Args:
seeds (lxml.etree.Element): The <seeds> XML element.
block (PeerInstructionXBlock): The XBlock with configuration to serialize.
Returns:
None | [
"Serialize",
"the",
"seeds",
"in",
"peer",
"instruction",
"XBlock",
"to",
"xml"
] | train | https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/serialize.py#L292-L307 |
ubc/ubcpi | ubcpi/serialize.py | serialize_to_xml | def serialize_to_xml(root, block):
"""
Serialize the Peer Instruction XBlock's content to XML.
Args:
block (PeerInstructionXBlock): The peer instruction block to serialize.
root (etree.Element): The XML root node to update.
Returns:
etree.Element
"""
root.tag = 'ubcpi'... | python | def serialize_to_xml(root, block):
"""
Serialize the Peer Instruction XBlock's content to XML.
Args:
block (PeerInstructionXBlock): The peer instruction block to serialize.
root (etree.Element): The XML root node to update.
Returns:
etree.Element
"""
root.tag = 'ubcpi'... | [
"def",
"serialize_to_xml",
"(",
"root",
",",
"block",
")",
":",
"root",
".",
"tag",
"=",
"'ubcpi'",
"if",
"block",
".",
"rationale_size",
"is",
"not",
"None",
":",
"if",
"block",
".",
"rationale_size",
".",
"get",
"(",
"'min'",
")",
":",
"root",
".",
... | Serialize the Peer Instruction XBlock's content to XML.
Args:
block (PeerInstructionXBlock): The peer instruction block to serialize.
root (etree.Element): The XML root node to update.
Returns:
etree.Element | [
"Serialize",
"the",
"Peer",
"Instruction",
"XBlock",
"s",
"content",
"to",
"XML",
"."
] | train | https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/serialize.py#L310-L348 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.open | def open(self):
"""
Obtains the lvm and vg_t handle. Usually you would never need to use this method
unless you are doing operations using the ctypes function wrappers in conversion.py
*Raises:*
* HandleError
"""
if not self.handle:
self.lvm.op... | python | def open(self):
"""
Obtains the lvm and vg_t handle. Usually you would never need to use this method
unless you are doing operations using the ctypes function wrappers in conversion.py
*Raises:*
* HandleError
"""
if not self.handle:
self.lvm.op... | [
"def",
"open",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"handle",
":",
"self",
".",
"lvm",
".",
"open",
"(",
")",
"self",
".",
"__vgh",
"=",
"lvm_vg_open",
"(",
"self",
".",
"lvm",
".",
"handle",
",",
"self",
".",
"name",
",",
"self",
"... | Obtains the lvm and vg_t handle. Usually you would never need to use this method
unless you are doing operations using the ctypes function wrappers in conversion.py
*Raises:*
* HandleError | [
"Obtains",
"the",
"lvm",
"and",
"vg_t",
"handle",
".",
"Usually",
"you",
"would",
"never",
"need",
"to",
"use",
"this",
"method",
"unless",
"you",
"are",
"doing",
"operations",
"using",
"the",
"ctypes",
"function",
"wrappers",
"in",
"conversion",
".",
"py"
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L67-L80 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.close | def close(self):
"""
Closes the lvm and vg_t handle. Usually you would never need to use this method
unless you are doing operations using the ctypes function wrappers in conversion.py
*Raises:*
* HandleError
"""
if self.handle:
cl = lvm_vg_clo... | python | def close(self):
"""
Closes the lvm and vg_t handle. Usually you would never need to use this method
unless you are doing operations using the ctypes function wrappers in conversion.py
*Raises:*
* HandleError
"""
if self.handle:
cl = lvm_vg_clo... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"handle",
":",
"cl",
"=",
"lvm_vg_close",
"(",
"self",
".",
"handle",
")",
"if",
"cl",
"!=",
"0",
":",
"raise",
"HandleError",
"(",
"\"Failed to close VG handle after init check.\"",
")",
"self",
".... | Closes the lvm and vg_t handle. Usually you would never need to use this method
unless you are doing operations using the ctypes function wrappers in conversion.py
*Raises:*
* HandleError | [
"Closes",
"the",
"lvm",
"and",
"vg_t",
"handle",
".",
"Usually",
"you",
"would",
"never",
"need",
"to",
"use",
"this",
"method",
"unless",
"you",
"are",
"doing",
"operations",
"using",
"the",
"ctypes",
"function",
"wrappers",
"in",
"conversion",
".",
"py"
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L82-L96 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.uuid | def uuid(self):
"""
Returns the volume group uuid.
"""
self.open()
uuid = lvm_vg_get_uuid(self.handle)
self.close()
return uuid | python | def uuid(self):
"""
Returns the volume group uuid.
"""
self.open()
uuid = lvm_vg_get_uuid(self.handle)
self.close()
return uuid | [
"def",
"uuid",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"uuid",
"=",
"lvm_vg_get_uuid",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"uuid"
] | Returns the volume group uuid. | [
"Returns",
"the",
"volume",
"group",
"uuid",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L120-L127 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.extent_count | def extent_count(self):
"""
Returns the volume group extent count.
"""
self.open()
count = lvm_vg_get_extent_count(self.handle)
self.close()
return count | python | def extent_count(self):
"""
Returns the volume group extent count.
"""
self.open()
count = lvm_vg_get_extent_count(self.handle)
self.close()
return count | [
"def",
"extent_count",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"count",
"=",
"lvm_vg_get_extent_count",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"count"
] | Returns the volume group extent count. | [
"Returns",
"the",
"volume",
"group",
"extent",
"count",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L137-L144 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.free_extent_count | def free_extent_count(self):
"""
Returns the volume group free extent count.
"""
self.open()
count = lvm_vg_get_free_extent_count(self.handle)
self.close()
return count | python | def free_extent_count(self):
"""
Returns the volume group free extent count.
"""
self.open()
count = lvm_vg_get_free_extent_count(self.handle)
self.close()
return count | [
"def",
"free_extent_count",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"count",
"=",
"lvm_vg_get_free_extent_count",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"count"
] | Returns the volume group free extent count. | [
"Returns",
"the",
"volume",
"group",
"free",
"extent",
"count",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L147-L154 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.pv_count | def pv_count(self):
"""
Returns the physical volume count.
"""
self.open()
count = lvm_vg_get_pv_count(self.handle)
self.close()
return count | python | def pv_count(self):
"""
Returns the physical volume count.
"""
self.open()
count = lvm_vg_get_pv_count(self.handle)
self.close()
return count | [
"def",
"pv_count",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"count",
"=",
"lvm_vg_get_pv_count",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"count"
] | Returns the physical volume count. | [
"Returns",
"the",
"physical",
"volume",
"count",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L157-L164 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.max_pv_count | def max_pv_count(self):
"""
Returns the maximum allowed physical volume count.
"""
self.open()
count = lvm_vg_get_max_pv(self.handle)
self.close()
return count | python | def max_pv_count(self):
"""
Returns the maximum allowed physical volume count.
"""
self.open()
count = lvm_vg_get_max_pv(self.handle)
self.close()
return count | [
"def",
"max_pv_count",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"count",
"=",
"lvm_vg_get_max_pv",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"count"
] | Returns the maximum allowed physical volume count. | [
"Returns",
"the",
"maximum",
"allowed",
"physical",
"volume",
"count",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L167-L174 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.max_lv_count | def max_lv_count(self):
"""
Returns the maximum allowed logical volume count.
"""
self.open()
count = lvm_vg_get_max_lv(self.handle)
self.close()
return count | python | def max_lv_count(self):
"""
Returns the maximum allowed logical volume count.
"""
self.open()
count = lvm_vg_get_max_lv(self.handle)
self.close()
return count | [
"def",
"max_lv_count",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"count",
"=",
"lvm_vg_get_max_lv",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"count"
] | Returns the maximum allowed logical volume count. | [
"Returns",
"the",
"maximum",
"allowed",
"logical",
"volume",
"count",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L177-L184 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.is_clustered | def is_clustered(self):
"""
Returns True if the VG is clustered, False otherwise.
"""
self.open()
clust = lvm_vg_is_clustered(self.handle)
self.close()
return bool(clust) | python | def is_clustered(self):
"""
Returns True if the VG is clustered, False otherwise.
"""
self.open()
clust = lvm_vg_is_clustered(self.handle)
self.close()
return bool(clust) | [
"def",
"is_clustered",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"clust",
"=",
"lvm_vg_is_clustered",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"bool",
"(",
"clust",
")"
] | Returns True if the VG is clustered, False otherwise. | [
"Returns",
"True",
"if",
"the",
"VG",
"is",
"clustered",
"False",
"otherwise",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L187-L194 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.is_exported | def is_exported(self):
"""
Returns True if the VG is exported, False otherwise.
"""
self.open()
exp = lvm_vg_is_exported(self.handle)
self.close()
return bool(exp) | python | def is_exported(self):
"""
Returns True if the VG is exported, False otherwise.
"""
self.open()
exp = lvm_vg_is_exported(self.handle)
self.close()
return bool(exp) | [
"def",
"is_exported",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"exp",
"=",
"lvm_vg_is_exported",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"bool",
"(",
"exp",
")"
] | Returns True if the VG is exported, False otherwise. | [
"Returns",
"True",
"if",
"the",
"VG",
"is",
"exported",
"False",
"otherwise",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L197-L204 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.is_partial | def is_partial(self):
"""
Returns True if the VG is partial, False otherwise.
"""
self.open()
part = lvm_vg_is_partial(self.handle)
self.close()
return bool(part) | python | def is_partial(self):
"""
Returns True if the VG is partial, False otherwise.
"""
self.open()
part = lvm_vg_is_partial(self.handle)
self.close()
return bool(part) | [
"def",
"is_partial",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"part",
"=",
"lvm_vg_is_partial",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"bool",
"(",
"part",
")"
] | Returns True if the VG is partial, False otherwise. | [
"Returns",
"True",
"if",
"the",
"VG",
"is",
"partial",
"False",
"otherwise",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L207-L214 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.sequence | def sequence(self):
"""
Returns the volume group sequence number. This number increases
everytime the volume group is modified.
"""
self.open()
seq = lvm_vg_get_seqno(self.handle)
self.close()
return seq | python | def sequence(self):
"""
Returns the volume group sequence number. This number increases
everytime the volume group is modified.
"""
self.open()
seq = lvm_vg_get_seqno(self.handle)
self.close()
return seq | [
"def",
"sequence",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"seq",
"=",
"lvm_vg_get_seqno",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"seq"
] | Returns the volume group sequence number. This number increases
everytime the volume group is modified. | [
"Returns",
"the",
"volume",
"group",
"sequence",
"number",
".",
"This",
"number",
"increases",
"everytime",
"the",
"volume",
"group",
"is",
"modified",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L217-L225 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.size | def size(self, units="MiB"):
"""
Returns the volume group size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
"""
self.open()
size = lvm_vg_get_size(self.handle)
self.close()... | python | def size(self, units="MiB"):
"""
Returns the volume group size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
"""
self.open()
size = lvm_vg_get_size(self.handle)
self.close()... | [
"def",
"size",
"(",
"self",
",",
"units",
"=",
"\"MiB\"",
")",
":",
"self",
".",
"open",
"(",
")",
"size",
"=",
"lvm_vg_get_size",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"size_convert",
"(",
"size",
",",
"units",
... | Returns the volume group size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB. | [
"Returns",
"the",
"volume",
"group",
"size",
"in",
"the",
"given",
"units",
".",
"Default",
"units",
"are",
"MiB",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L227-L238 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.free_size | def free_size(self, units="MiB"):
"""
Returns the volume group free size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
"""
self.open()
size = lvm_vg_get_free_size(self.handle)
... | python | def free_size(self, units="MiB"):
"""
Returns the volume group free size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
"""
self.open()
size = lvm_vg_get_free_size(self.handle)
... | [
"def",
"free_size",
"(",
"self",
",",
"units",
"=",
"\"MiB\"",
")",
":",
"self",
".",
"open",
"(",
")",
"size",
"=",
"lvm_vg_get_free_size",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"size_convert",
"(",
"size",
",",
... | Returns the volume group free size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB. | [
"Returns",
"the",
"volume",
"group",
"free",
"size",
"in",
"the",
"given",
"units",
".",
"Default",
"units",
"are",
"MiB",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L240-L251 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.extent_size | def extent_size(self, units="MiB"):
"""
Returns the volume group extent size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
"""
self.open()
size = lvm_vg_get_extent_size(self.handle)... | python | def extent_size(self, units="MiB"):
"""
Returns the volume group extent size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
"""
self.open()
size = lvm_vg_get_extent_size(self.handle)... | [
"def",
"extent_size",
"(",
"self",
",",
"units",
"=",
"\"MiB\"",
")",
":",
"self",
".",
"open",
"(",
")",
"size",
"=",
"lvm_vg_get_extent_size",
"(",
"self",
".",
"handle",
")",
"self",
".",
"close",
"(",
")",
"return",
"size_convert",
"(",
"size",
","... | Returns the volume group extent size in the given units. Default units are MiB.
*Args:*
* units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB. | [
"Returns",
"the",
"volume",
"group",
"extent",
"size",
"in",
"the",
"given",
"units",
".",
"Default",
"units",
"are",
"MiB",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L253-L264 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.add_pv | def add_pv(self, device):
"""
Initializes a device as a physical volume and adds it to the volume group::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
vg.add_pv("/dev/sdbX")
*Args:*
* device (str): An existing d... | python | def add_pv(self, device):
"""
Initializes a device as a physical volume and adds it to the volume group::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
vg.add_pv("/dev/sdbX")
*Args:*
* device (str): An existing d... | [
"def",
"add_pv",
"(",
"self",
",",
"device",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"device",
")",
":",
"raise",
"ValueError",
"(",
"\"%s does not exist.\"",
"%",
"device",
")",
"self",
".",
"open",
"(",
")",
"ext",
"=",
"lvm_v... | Initializes a device as a physical volume and adds it to the volume group::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
vg.add_pv("/dev/sdbX")
*Args:*
* device (str): An existing device.
*Raises:*
* Val... | [
"Initializes",
"a",
"device",
"as",
"a",
"physical",
"volume",
"and",
"adds",
"it",
"to",
"the",
"volume",
"group",
"::"
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L272-L304 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.get_pv | def get_pv(self, device):
"""
Returns the physical volume associated with the given device::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
vg.get_pv("/dev/sdb1")
*Args:*
* device (str): An existing device.
... | python | def get_pv(self, device):
"""
Returns the physical volume associated with the given device::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
vg.get_pv("/dev/sdb1")
*Args:*
* device (str): An existing device.
... | [
"def",
"get_pv",
"(",
"self",
",",
"device",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"device",
")",
":",
"raise",
"ValueError",
"(",
"\"%s does not exist.\"",
"%",
"device",
")",
"return",
"PhysicalVolume",
"(",
"self",
",",
"name",... | Returns the physical volume associated with the given device::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
vg.get_pv("/dev/sdb1")
*Args:*
* device (str): An existing device.
*Raises:*
* ValueError, Hand... | [
"Returns",
"the",
"physical",
"volume",
"associated",
"with",
"the",
"given",
"device",
"::"
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L306-L326 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.remove_pv | def remove_pv(self, pv):
"""
Removes a physical volume from the volume group::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
pv = vg.pvscan()[0]
vg.remove_pv(pv)
*Args:*
* pv (obj): A PhysicalVolu... | python | def remove_pv(self, pv):
"""
Removes a physical volume from the volume group::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
pv = vg.pvscan()[0]
vg.remove_pv(pv)
*Args:*
* pv (obj): A PhysicalVolu... | [
"def",
"remove_pv",
"(",
"self",
",",
"pv",
")",
":",
"name",
"=",
"pv",
".",
"name",
"self",
".",
"open",
"(",
")",
"rm",
"=",
"lvm_vg_reduce",
"(",
"self",
".",
"handle",
",",
"name",
")",
"if",
"rm",
"!=",
"0",
":",
"self",
".",
"close",
"("... | Removes a physical volume from the volume group::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
pv = vg.pvscan()[0]
vg.remove_pv(pv)
*Args:*
* pv (obj): A PhysicalVolume instance.
*Raises:*
* ... | [
"Removes",
"a",
"physical",
"volume",
"from",
"the",
"volume",
"group",
"::"
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L348-L380 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.pvscan | def pvscan(self):
"""
Probes the volume group for physical volumes and returns a list of
PhysicalVolume instances::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg")
pvs = vg.pvscan()
*Raises:*
* HandleError
... | python | def pvscan(self):
"""
Probes the volume group for physical volumes and returns a list of
PhysicalVolume instances::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg")
pvs = vg.pvscan()
*Raises:*
* HandleError
... | [
"def",
"pvscan",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"pv_list",
"=",
"[",
"]",
"pv_handles",
"=",
"lvm_vg_list_pvs",
"(",
"self",
".",
"handle",
")",
"if",
"not",
"bool",
"(",
"pv_handles",
")",
":",
"return",
"pv_list",
"pvh",
"=",... | Probes the volume group for physical volumes and returns a list of
PhysicalVolume instances::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg")
pvs = vg.pvscan()
*Raises:*
* HandleError | [
"Probes",
"the",
"volume",
"group",
"for",
"physical",
"volumes",
"and",
"returns",
"a",
"list",
"of",
"PhysicalVolume",
"instances",
"::"
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L382-L412 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.lvscan | def lvscan(self):
"""
Probes the volume group for logical volumes and returns a list of
LogicalVolume instances::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg")
lvs = vg.lvscan()
*Raises:*
* HandleError
"... | python | def lvscan(self):
"""
Probes the volume group for logical volumes and returns a list of
LogicalVolume instances::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg")
lvs = vg.lvscan()
*Raises:*
* HandleError
"... | [
"def",
"lvscan",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"lv_list",
"=",
"[",
"]",
"lv_handles",
"=",
"lvm_vg_list_lvs",
"(",
"self",
".",
"handle",
")",
"if",
"not",
"bool",
"(",
"lv_handles",
")",
":",
"return",
"lv_list",
"lvh",
"=",... | Probes the volume group for logical volumes and returns a list of
LogicalVolume instances::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg")
lvs = vg.lvscan()
*Raises:*
* HandleError | [
"Probes",
"the",
"volume",
"group",
"for",
"logical",
"volumes",
"and",
"returns",
"a",
"list",
"of",
"LogicalVolume",
"instances",
"::"
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L414-L444 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.create_lv | def create_lv(self, name, length, units):
"""
Creates a logical volume and returns the LogicalVolume instance associated with
the lv_t handle::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
lv = vg.create_lv("mylv", 40, "MiB")
... | python | def create_lv(self, name, length, units):
"""
Creates a logical volume and returns the LogicalVolume instance associated with
the lv_t handle::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
lv = vg.create_lv("mylv", 40, "MiB")
... | [
"def",
"create_lv",
"(",
"self",
",",
"name",
",",
"length",
",",
"units",
")",
":",
"if",
"units",
"!=",
"\"%\"",
":",
"size",
"=",
"size_units",
"[",
"units",
"]",
"*",
"length",
"else",
":",
"if",
"not",
"(",
"0",
"<",
"length",
"<=",
"100",
"... | Creates a logical volume and returns the LogicalVolume instance associated with
the lv_t handle::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
lv = vg.create_lv("mylv", 40, "MiB")
*Args:*
* name (str): The des... | [
"Creates",
"a",
"logical",
"volume",
"and",
"returns",
"the",
"LogicalVolume",
"instance",
"associated",
"with",
"the",
"lv_t",
"handle",
"::"
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L446-L485 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.remove_lv | def remove_lv(self, lv):
"""
Removes a logical volume from the volume group::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
lv = vg.lvscan()[0]
vg.remove_lv(lv)
*Args:*
* lv (obj): A LogicalVolume... | python | def remove_lv(self, lv):
"""
Removes a logical volume from the volume group::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
lv = vg.lvscan()[0]
vg.remove_lv(lv)
*Args:*
* lv (obj): A LogicalVolume... | [
"def",
"remove_lv",
"(",
"self",
",",
"lv",
")",
":",
"lv",
".",
"open",
"(",
")",
"rm",
"=",
"lvm_vg_remove_lv",
"(",
"lv",
".",
"handle",
")",
"lv",
".",
"close",
"(",
")",
"if",
"rm",
"!=",
"0",
":",
"raise",
"CommitError",
"(",
"\"Failed to rem... | Removes a logical volume from the volume group::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
lv = vg.lvscan()[0]
vg.remove_lv(lv)
*Args:*
* lv (obj): A LogicalVolume instance.
*Raises:*
* ... | [
"Removes",
"a",
"logical",
"volume",
"from",
"the",
"volume",
"group",
"::"
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L487-L515 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.remove_all_lvs | def remove_all_lvs(self):
"""
Removes all logical volumes from the volume group.
*Raises:*
* HandleError, CommitError
"""
lvs = self.lvscan()
for lv in lvs:
self.remove_lv(lv) | python | def remove_all_lvs(self):
"""
Removes all logical volumes from the volume group.
*Raises:*
* HandleError, CommitError
"""
lvs = self.lvscan()
for lv in lvs:
self.remove_lv(lv) | [
"def",
"remove_all_lvs",
"(",
"self",
")",
":",
"lvs",
"=",
"self",
".",
"lvscan",
"(",
")",
"for",
"lv",
"in",
"lvs",
":",
"self",
".",
"remove_lv",
"(",
"lv",
")"
] | Removes all logical volumes from the volume group.
*Raises:*
* HandleError, CommitError | [
"Removes",
"all",
"logical",
"volumes",
"from",
"the",
"volume",
"group",
"."
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L517-L527 |
xzased/lvm2py | lvm2py/vg.py | VolumeGroup.set_extent_size | def set_extent_size(self, length, units):
"""
Sets the volume group extent size in the given units::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
vg.set_extent_size(2, "MiB")
*Args:*
* length (int): The desired ... | python | def set_extent_size(self, length, units):
"""
Sets the volume group extent size in the given units::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
vg.set_extent_size(2, "MiB")
*Args:*
* length (int): The desired ... | [
"def",
"set_extent_size",
"(",
"self",
",",
"length",
",",
"units",
")",
":",
"size",
"=",
"length",
"*",
"size_units",
"[",
"units",
"]",
"self",
".",
"open",
"(",
")",
"ext",
"=",
"lvm_vg_set_extent_size",
"(",
"self",
".",
"handle",
",",
"c_ulong",
... | Sets the volume group extent size in the given units::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
vg.set_extent_size(2, "MiB")
*Args:*
* length (int): The desired length size.
* units (str): The desired units... | [
"Sets",
"the",
"volume",
"group",
"extent",
"size",
"in",
"the",
"given",
"units",
"::"
] | train | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L541-L571 |
davidmcclure/textplot | textplot/matrix.py | Matrix.set_pair | def set_pair(self, term1, term2, value, **kwargs):
"""
Set the value for a pair of terms.
Args:
term1 (str)
term2 (str)
value (mixed)
"""
key = self.key(term1, term2)
self.keys.update([term1, term2])
self.pairs[key] = value | python | def set_pair(self, term1, term2, value, **kwargs):
"""
Set the value for a pair of terms.
Args:
term1 (str)
term2 (str)
value (mixed)
"""
key = self.key(term1, term2)
self.keys.update([term1, term2])
self.pairs[key] = value | [
"def",
"set_pair",
"(",
"self",
",",
"term1",
",",
"term2",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"key",
"=",
"self",
".",
"key",
"(",
"term1",
",",
"term2",
")",
"self",
".",
"keys",
".",
"update",
"(",
"[",
"term1",
",",
"term2",
"... | Set the value for a pair of terms.
Args:
term1 (str)
term2 (str)
value (mixed) | [
"Set",
"the",
"value",
"for",
"a",
"pair",
"of",
"terms",
"."
] | train | https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/matrix.py#L50-L63 |
davidmcclure/textplot | textplot/matrix.py | Matrix.get_pair | def get_pair(self, term1, term2):
"""
Get the value for a pair of terms.
Args:
term1 (str)
term2 (str)
Returns:
The stored value.
"""
key = self.key(term1, term2)
return self.pairs.get(key, None) | python | def get_pair(self, term1, term2):
"""
Get the value for a pair of terms.
Args:
term1 (str)
term2 (str)
Returns:
The stored value.
"""
key = self.key(term1, term2)
return self.pairs.get(key, None) | [
"def",
"get_pair",
"(",
"self",
",",
"term1",
",",
"term2",
")",
":",
"key",
"=",
"self",
".",
"key",
"(",
"term1",
",",
"term2",
")",
"return",
"self",
".",
"pairs",
".",
"get",
"(",
"key",
",",
"None",
")"
] | Get the value for a pair of terms.
Args:
term1 (str)
term2 (str)
Returns:
The stored value. | [
"Get",
"the",
"value",
"for",
"a",
"pair",
"of",
"terms",
"."
] | train | https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/matrix.py#L66-L80 |
davidmcclure/textplot | textplot/matrix.py | Matrix.index | def index(self, text, terms=None, **kwargs):
"""
Index all term pair distances.
Args:
text (Text): The source text.
terms (list): Terms to index.
"""
self.clear()
# By default, use all terms.
terms = terms or text.terms.keys()
... | python | def index(self, text, terms=None, **kwargs):
"""
Index all term pair distances.
Args:
text (Text): The source text.
terms (list): Terms to index.
"""
self.clear()
# By default, use all terms.
terms = terms or text.terms.keys()
... | [
"def",
"index",
"(",
"self",
",",
"text",
",",
"terms",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"clear",
"(",
")",
"# By default, use all terms.",
"terms",
"=",
"terms",
"or",
"text",
".",
"terms",
".",
"keys",
"(",
")",
"pairs",... | Index all term pair distances.
Args:
text (Text): The source text.
terms (list): Terms to index. | [
"Index",
"all",
"term",
"pair",
"distances",
"."
] | train | https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/matrix.py#L83-L105 |
davidmcclure/textplot | textplot/matrix.py | Matrix.anchored_pairs | def anchored_pairs(self, anchor):
"""
Get distances between an anchor term and all other terms.
Args:
anchor (str): The anchor term.
Returns:
OrderedDict: The distances, in descending order.
"""
pairs = OrderedDict()
for term in self.k... | python | def anchored_pairs(self, anchor):
"""
Get distances between an anchor term and all other terms.
Args:
anchor (str): The anchor term.
Returns:
OrderedDict: The distances, in descending order.
"""
pairs = OrderedDict()
for term in self.k... | [
"def",
"anchored_pairs",
"(",
"self",
",",
"anchor",
")",
":",
"pairs",
"=",
"OrderedDict",
"(",
")",
"for",
"term",
"in",
"self",
".",
"keys",
":",
"score",
"=",
"self",
".",
"get_pair",
"(",
"anchor",
",",
"term",
")",
"if",
"score",
":",
"pairs",
... | Get distances between an anchor term and all other terms.
Args:
anchor (str): The anchor term.
Returns:
OrderedDict: The distances, in descending order. | [
"Get",
"distances",
"between",
"an",
"anchor",
"term",
"and",
"all",
"other",
"terms",
"."
] | train | https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/matrix.py#L108-L126 |
magarcia/python-x256 | x256/x256.py | from_rgb | def from_rgb(r, g=None, b=None):
"""
Return the nearest xterm 256 color code from rgb input.
"""
c = r if isinstance(r, list) else [r, g, b]
best = {}
for index, item in enumerate(colors):
d = __distance(item, c)
if(not best or d <= best['distance']):
best = {'distan... | python | def from_rgb(r, g=None, b=None):
"""
Return the nearest xterm 256 color code from rgb input.
"""
c = r if isinstance(r, list) else [r, g, b]
best = {}
for index, item in enumerate(colors):
d = __distance(item, c)
if(not best or d <= best['distance']):
best = {'distan... | [
"def",
"from_rgb",
"(",
"r",
",",
"g",
"=",
"None",
",",
"b",
"=",
"None",
")",
":",
"c",
"=",
"r",
"if",
"isinstance",
"(",
"r",
",",
"list",
")",
"else",
"[",
"r",
",",
"g",
",",
"b",
"]",
"best",
"=",
"{",
"}",
"for",
"index",
",",
"it... | Return the nearest xterm 256 color code from rgb input. | [
"Return",
"the",
"nearest",
"xterm",
"256",
"color",
"code",
"from",
"rgb",
"input",
"."
] | train | https://github.com/magarcia/python-x256/blob/d4bc9f763a34eb15cce4f23a2e09eff3adc8a032/x256/x256.py#L283-L298 |
magarcia/python-x256 | x256/x256.py | entry | def entry():
"""Parse command line arguments and run utilities."""
parser = argparse.ArgumentParser()
parser.add_argument(
'action', help='Action to take',
choices=['from_hex', 'to_rgb', 'to_hex'],
)
parser.add_argument(
'value', help='Value for the action',
)
parsed ... | python | def entry():
"""Parse command line arguments and run utilities."""
parser = argparse.ArgumentParser()
parser.add_argument(
'action', help='Action to take',
choices=['from_hex', 'to_rgb', 'to_hex'],
)
parser.add_argument(
'value', help='Value for the action',
)
parsed ... | [
"def",
"entry",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'action'",
",",
"help",
"=",
"'Action to take'",
",",
"choices",
"=",
"[",
"'from_hex'",
",",
"'to_rgb'",
",",
"'to_hex'",
"]",
... | Parse command line arguments and run utilities. | [
"Parse",
"command",
"line",
"arguments",
"and",
"run",
"utilities",
"."
] | train | https://github.com/magarcia/python-x256/blob/d4bc9f763a34eb15cce4f23a2e09eff3adc8a032/x256/x256.py#L321-L339 |
twisted/axiom | axiom/listversions.py | makeSoftwareVersion | def makeSoftwareVersion(store, version, systemVersion):
"""
Return the SoftwareVersion object from store corresponding to the
version object, creating it if it doesn't already exist.
"""
return store.findOrCreate(SoftwareVersion,
systemVersion=systemVersion,
... | python | def makeSoftwareVersion(store, version, systemVersion):
"""
Return the SoftwareVersion object from store corresponding to the
version object, creating it if it doesn't already exist.
"""
return store.findOrCreate(SoftwareVersion,
systemVersion=systemVersion,
... | [
"def",
"makeSoftwareVersion",
"(",
"store",
",",
"version",
",",
"systemVersion",
")",
":",
"return",
"store",
".",
"findOrCreate",
"(",
"SoftwareVersion",
",",
"systemVersion",
"=",
"systemVersion",
",",
"package",
"=",
"unicode",
"(",
"version",
".",
"package"... | Return the SoftwareVersion object from store corresponding to the
version object, creating it if it doesn't already exist. | [
"Return",
"the",
"SoftwareVersion",
"object",
"from",
"store",
"corresponding",
"to",
"the",
"version",
"object",
"creating",
"it",
"if",
"it",
"doesn",
"t",
"already",
"exist",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/listversions.py#L91-L102 |
twisted/axiom | axiom/listversions.py | listVersionHistory | def listVersionHistory(store):
"""
List the software package version history of store.
"""
q = store.query(SystemVersion, sort=SystemVersion.creation.descending)
return [sv.longWindedRepr() for sv in q] | python | def listVersionHistory(store):
"""
List the software package version history of store.
"""
q = store.query(SystemVersion, sort=SystemVersion.creation.descending)
return [sv.longWindedRepr() for sv in q] | [
"def",
"listVersionHistory",
"(",
"store",
")",
":",
"q",
"=",
"store",
".",
"query",
"(",
"SystemVersion",
",",
"sort",
"=",
"SystemVersion",
".",
"creation",
".",
"descending",
")",
"return",
"[",
"sv",
".",
"longWindedRepr",
"(",
")",
"for",
"sv",
"in... | List the software package version history of store. | [
"List",
"the",
"software",
"package",
"version",
"history",
"of",
"store",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/listversions.py#L106-L111 |
twisted/axiom | axiom/listversions.py | checkSystemVersion | def checkSystemVersion(s, versions=None):
"""
Check if the current version is different from the previously recorded
version. If it is, or if there is no previously recorded version,
create a version matching the current config.
"""
if versions is None:
versions = getSystemVersions()
... | python | def checkSystemVersion(s, versions=None):
"""
Check if the current version is different from the previously recorded
version. If it is, or if there is no previously recorded version,
create a version matching the current config.
"""
if versions is None:
versions = getSystemVersions()
... | [
"def",
"checkSystemVersion",
"(",
"s",
",",
"versions",
"=",
"None",
")",
":",
"if",
"versions",
"is",
"None",
":",
"versions",
"=",
"getSystemVersions",
"(",
")",
"currentVersionMap",
"=",
"dict",
"(",
"[",
"(",
"v",
".",
"package",
",",
"v",
")",
"fo... | Check if the current version is different from the previously recorded
version. If it is, or if there is no previously recorded version,
create a version matching the current config. | [
"Check",
"if",
"the",
"current",
"version",
"is",
"different",
"from",
"the",
"previously",
"recorded",
"version",
".",
"If",
"it",
"is",
"or",
"if",
"there",
"is",
"no",
"previously",
"recorded",
"version",
"create",
"a",
"version",
"matching",
"the",
"curr... | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/listversions.py#L121-L142 |
twisted/axiom | axiom/listversions.py | SoftwareVersion.asVersion | def asVersion(self):
"""
Convert the version data in this item to a
L{twisted.python.versions.Version}.
"""
return versions.Version(self.package, self.major, self.minor, self.micro) | python | def asVersion(self):
"""
Convert the version data in this item to a
L{twisted.python.versions.Version}.
"""
return versions.Version(self.package, self.major, self.minor, self.micro) | [
"def",
"asVersion",
"(",
"self",
")",
":",
"return",
"versions",
".",
"Version",
"(",
"self",
".",
"package",
",",
"self",
".",
"major",
",",
"self",
".",
"minor",
",",
"self",
".",
"micro",
")"
] | Convert the version data in this item to a
L{twisted.python.versions.Version}. | [
"Convert",
"the",
"version",
"data",
"in",
"this",
"item",
"to",
"a",
"L",
"{",
"twisted",
".",
"python",
".",
"versions",
".",
"Version",
"}",
"."
] | train | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/listversions.py#L78-L83 |
swharden/PyOriginTools | PyOriginTools/workbook.py | SHEET.reset | def reset(self):
"""clears all columns"""
self.colNames,self.colDesc,self.colUnits,self.colComments,\
self.colTypes,self.colData=[],[],[],[],[],[] | python | def reset(self):
"""clears all columns"""
self.colNames,self.colDesc,self.colUnits,self.colComments,\
self.colTypes,self.colData=[],[],[],[],[],[] | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"colNames",
",",
"self",
".",
"colDesc",
",",
"self",
".",
"colUnits",
",",
"self",
".",
"colComments",
",",
"self",
".",
"colTypes",
",",
"self",
".",
"colData",
"=",
"[",
"]",
",",
"[",
"]",
"... | clears all columns | [
"clears",
"all",
"columns"
] | train | https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L42-L45 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.