id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
232,000 | projecthamster/hamster | src/hamster/idle.py | DbusIdleListener.bus_inspector | def bus_inspector(self, bus, message):
"""
Inspect the bus for screensaver messages of interest
"""
# We only care about stuff on this interface. We did filter
# for it above, but even so we still hear from ourselves
# (hamster messages).
if message.get_interfac... | python | def bus_inspector(self, bus, message):
"""
Inspect the bus for screensaver messages of interest
"""
# We only care about stuff on this interface. We did filter
# for it above, but even so we still hear from ourselves
# (hamster messages).
if message.get_interfac... | [
"def",
"bus_inspector",
"(",
"self",
",",
"bus",
",",
"message",
")",
":",
"# We only care about stuff on this interface. We did filter",
"# for it above, but even so we still hear from ourselves",
"# (hamster messages).",
"if",
"message",
".",
"get_interface",
"(",
")",
"!=",... | Inspect the bus for screensaver messages of interest | [
"Inspect",
"the",
"bus",
"for",
"screensaver",
"messages",
"of",
"interest"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/idle.py#L77-L134 |
232,001 | projecthamster/hamster | src/hamster/lib/i18n.py | C_ | def C_(ctx, s):
"""Provide qualified translatable strings via context.
Taken from gnome-games.
"""
translated = gettext.gettext('%s\x04%s' % (ctx, s))
if '\x04' in translated:
# no translation found, return input string
return s
return translated | python | def C_(ctx, s):
"""Provide qualified translatable strings via context.
Taken from gnome-games.
"""
translated = gettext.gettext('%s\x04%s' % (ctx, s))
if '\x04' in translated:
# no translation found, return input string
return s
return translated | [
"def",
"C_",
"(",
"ctx",
",",
"s",
")",
":",
"translated",
"=",
"gettext",
".",
"gettext",
"(",
"'%s\\x04%s'",
"%",
"(",
"ctx",
",",
"s",
")",
")",
"if",
"'\\x04'",
"in",
"translated",
":",
"# no translation found, return input string",
"return",
"s",
"ret... | Provide qualified translatable strings via context.
Taken from gnome-games. | [
"Provide",
"qualified",
"translatable",
"strings",
"via",
"context",
".",
"Taken",
"from",
"gnome",
"-",
"games",
"."
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/i18n.py#L34-L42 |
232,002 | projecthamster/hamster | wafadmin/Scripting.py | clean | def clean(bld):
'''removes the build files'''
try:
proj=Environment.Environment(Options.lockfile)
except IOError:
raise Utils.WafError('Nothing to clean (project not configured)')
bld.load_dirs(proj[SRCDIR],proj[BLDDIR])
bld.load_envs()
bld.is_install=0
bld.add_subdirs([os.path.split(Utils.g_module.root_path... | python | def clean(bld):
'''removes the build files'''
try:
proj=Environment.Environment(Options.lockfile)
except IOError:
raise Utils.WafError('Nothing to clean (project not configured)')
bld.load_dirs(proj[SRCDIR],proj[BLDDIR])
bld.load_envs()
bld.is_install=0
bld.add_subdirs([os.path.split(Utils.g_module.root_path... | [
"def",
"clean",
"(",
"bld",
")",
":",
"try",
":",
"proj",
"=",
"Environment",
".",
"Environment",
"(",
"Options",
".",
"lockfile",
")",
"except",
"IOError",
":",
"raise",
"Utils",
".",
"WafError",
"(",
"'Nothing to clean (project not configured)'",
")",
"bld",... | removes the build files | [
"removes",
"the",
"build",
"files"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/wafadmin/Scripting.py#L188-L201 |
232,003 | projecthamster/hamster | wafadmin/Scripting.py | install | def install(bld):
'''installs the build files'''
bld=check_configured(bld)
Options.commands['install']=True
Options.commands['uninstall']=False
Options.is_install=True
bld.is_install=INSTALL
build_impl(bld)
bld.install() | python | def install(bld):
'''installs the build files'''
bld=check_configured(bld)
Options.commands['install']=True
Options.commands['uninstall']=False
Options.is_install=True
bld.is_install=INSTALL
build_impl(bld)
bld.install() | [
"def",
"install",
"(",
"bld",
")",
":",
"bld",
"=",
"check_configured",
"(",
"bld",
")",
"Options",
".",
"commands",
"[",
"'install'",
"]",
"=",
"True",
"Options",
".",
"commands",
"[",
"'uninstall'",
"]",
"=",
"False",
"Options",
".",
"is_install",
"=",... | installs the build files | [
"installs",
"the",
"build",
"files"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/wafadmin/Scripting.py#L248-L256 |
232,004 | projecthamster/hamster | wafadmin/Scripting.py | uninstall | def uninstall(bld):
'''removes the installed files'''
Options.commands['install']=False
Options.commands['uninstall']=True
Options.is_install=True
bld.is_install=UNINSTALL
try:
def runnable_status(self):
return SKIP_ME
setattr(Task.Task,'runnable_status_back',Task.Task.runnable_status)
setattr(Task.Task,... | python | def uninstall(bld):
'''removes the installed files'''
Options.commands['install']=False
Options.commands['uninstall']=True
Options.is_install=True
bld.is_install=UNINSTALL
try:
def runnable_status(self):
return SKIP_ME
setattr(Task.Task,'runnable_status_back',Task.Task.runnable_status)
setattr(Task.Task,... | [
"def",
"uninstall",
"(",
"bld",
")",
":",
"Options",
".",
"commands",
"[",
"'install'",
"]",
"=",
"False",
"Options",
".",
"commands",
"[",
"'uninstall'",
"]",
"=",
"True",
"Options",
".",
"is_install",
"=",
"True",
"bld",
".",
"is_install",
"=",
"UNINST... | removes the installed files | [
"removes",
"the",
"installed",
"files"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/wafadmin/Scripting.py#L257-L271 |
232,005 | projecthamster/hamster | wafadmin/Scripting.py | distclean | def distclean(ctx=None):
'''removes the build directory'''
global commands
lst=os.listdir('.')
for f in lst:
if f==Options.lockfile:
try:
proj=Environment.Environment(f)
except:
Logs.warn('could not read %r'%f)
continue
try:
shutil.rmtree(proj[BLDDIR])
except IOError:
pass
excep... | python | def distclean(ctx=None):
'''removes the build directory'''
global commands
lst=os.listdir('.')
for f in lst:
if f==Options.lockfile:
try:
proj=Environment.Environment(f)
except:
Logs.warn('could not read %r'%f)
continue
try:
shutil.rmtree(proj[BLDDIR])
except IOError:
pass
excep... | [
"def",
"distclean",
"(",
"ctx",
"=",
"None",
")",
":",
"global",
"commands",
"lst",
"=",
"os",
".",
"listdir",
"(",
"'.'",
")",
"for",
"f",
"in",
"lst",
":",
"if",
"f",
"==",
"Options",
".",
"lockfile",
":",
"try",
":",
"proj",
"=",
"Environment",
... | removes the build directory | [
"removes",
"the",
"build",
"directory"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/wafadmin/Scripting.py#L318-L342 |
232,006 | projecthamster/hamster | wafadmin/Scripting.py | dist | def dist(appname='',version=''):
'''makes a tarball for redistributing the sources'''
import tarfile
if not appname:appname=Utils.g_module.APPNAME
if not version:version=Utils.g_module.VERSION
tmp_folder=appname+'-'+version
if g_gz in['gz','bz2']:
arch_name=tmp_folder+'.tar.'+g_gz
else:
arch_name=tmp_folder+... | python | def dist(appname='',version=''):
'''makes a tarball for redistributing the sources'''
import tarfile
if not appname:appname=Utils.g_module.APPNAME
if not version:version=Utils.g_module.VERSION
tmp_folder=appname+'-'+version
if g_gz in['gz','bz2']:
arch_name=tmp_folder+'.tar.'+g_gz
else:
arch_name=tmp_folder+... | [
"def",
"dist",
"(",
"appname",
"=",
"''",
",",
"version",
"=",
"''",
")",
":",
"import",
"tarfile",
"if",
"not",
"appname",
":",
"appname",
"=",
"Utils",
".",
"g_module",
".",
"APPNAME",
"if",
"not",
"version",
":",
"version",
"=",
"Utils",
".",
"g_m... | makes a tarball for redistributing the sources | [
"makes",
"a",
"tarball",
"for",
"redistributing",
"the",
"sources"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/wafadmin/Scripting.py#L343-L387 |
232,007 | projecthamster/hamster | src/hamster/widgets/reportchooserdialog.py | ReportChooserDialog.show | def show(self, start_date, end_date):
"""setting suggested name to something readable, replace backslashes
with dots so the name is valid in linux"""
# title in the report file name
vars = {"title": _("Time track"),
"start": start_date.strftime("%x").replace("/", ".")... | python | def show(self, start_date, end_date):
"""setting suggested name to something readable, replace backslashes
with dots so the name is valid in linux"""
# title in the report file name
vars = {"title": _("Time track"),
"start": start_date.strftime("%x").replace("/", ".")... | [
"def",
"show",
"(",
"self",
",",
"start_date",
",",
"end_date",
")",
":",
"# title in the report file name",
"vars",
"=",
"{",
"\"title\"",
":",
"_",
"(",
"\"Time track\"",
")",
",",
"\"start\"",
":",
"start_date",
".",
"strftime",
"(",
"\"%x\"",
")",
".",
... | setting suggested name to something readable, replace backslashes
with dots so the name is valid in linux | [
"setting",
"suggested",
"name",
"to",
"something",
"readable",
"replace",
"backslashes",
"with",
"dots",
"so",
"the",
"name",
"is",
"valid",
"in",
"linux"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/widgets/reportchooserdialog.py#L90-L112 |
232,008 | projecthamster/hamster | src/hamster/lib/pytweener.py | Tweener.kill_tweens | def kill_tweens(self, obj = None):
"""Stop tweening an object, without completing the motion or firing the
on_complete"""
if obj is not None:
try:
del self.current_tweens[obj]
except:
pass
else:
self.current_tweens = col... | python | def kill_tweens(self, obj = None):
"""Stop tweening an object, without completing the motion or firing the
on_complete"""
if obj is not None:
try:
del self.current_tweens[obj]
except:
pass
else:
self.current_tweens = col... | [
"def",
"kill_tweens",
"(",
"self",
",",
"obj",
"=",
"None",
")",
":",
"if",
"obj",
"is",
"not",
"None",
":",
"try",
":",
"del",
"self",
".",
"current_tweens",
"[",
"obj",
"]",
"except",
":",
"pass",
"else",
":",
"self",
".",
"current_tweens",
"=",
... | Stop tweening an object, without completing the motion or firing the
on_complete | [
"Stop",
"tweening",
"an",
"object",
"without",
"completing",
"the",
"motion",
"or",
"firing",
"the",
"on_complete"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/pytweener.py#L72-L81 |
232,009 | projecthamster/hamster | src/hamster/lib/pytweener.py | Tweener.remove_tween | def remove_tween(self, tween):
""""remove given tween without completing the motion or firing the on_complete"""
if tween.target in self.current_tweens and tween in self.current_tweens[tween.target]:
self.current_tweens[tween.target].remove(tween)
if not self.current_tweens[tween... | python | def remove_tween(self, tween):
""""remove given tween without completing the motion or firing the on_complete"""
if tween.target in self.current_tweens and tween in self.current_tweens[tween.target]:
self.current_tweens[tween.target].remove(tween)
if not self.current_tweens[tween... | [
"def",
"remove_tween",
"(",
"self",
",",
"tween",
")",
":",
"if",
"tween",
".",
"target",
"in",
"self",
".",
"current_tweens",
"and",
"tween",
"in",
"self",
".",
"current_tweens",
"[",
"tween",
".",
"target",
"]",
":",
"self",
".",
"current_tweens",
"[",... | remove given tween without completing the motion or firing the on_complete | [
"remove",
"given",
"tween",
"without",
"completing",
"the",
"motion",
"or",
"firing",
"the",
"on_complete"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/pytweener.py#L83-L88 |
232,010 | projecthamster/hamster | src/hamster/lib/pytweener.py | Tweener.finish | def finish(self):
"""jump the the last frame of all tweens"""
for obj in self.current_tweens:
for tween in self.current_tweens[obj]:
tween.finish()
self.current_tweens = {} | python | def finish(self):
"""jump the the last frame of all tweens"""
for obj in self.current_tweens:
for tween in self.current_tweens[obj]:
tween.finish()
self.current_tweens = {} | [
"def",
"finish",
"(",
"self",
")",
":",
"for",
"obj",
"in",
"self",
".",
"current_tweens",
":",
"for",
"tween",
"in",
"self",
".",
"current_tweens",
"[",
"obj",
"]",
":",
"tween",
".",
"finish",
"(",
")",
"self",
".",
"current_tweens",
"=",
"{",
"}"
... | jump the the last frame of all tweens | [
"jump",
"the",
"the",
"last",
"frame",
"of",
"all",
"tweens"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/pytweener.py#L90-L95 |
232,011 | projecthamster/hamster | src/hamster/lib/pytweener.py | Tweener.update | def update(self, delta_seconds):
"""update tweeners. delta_seconds is time in seconds since last frame"""
for obj in tuple(self.current_tweens):
for tween in tuple(self.current_tweens[obj]):
done = tween.update(delta_seconds)
if done:
self... | python | def update(self, delta_seconds):
"""update tweeners. delta_seconds is time in seconds since last frame"""
for obj in tuple(self.current_tweens):
for tween in tuple(self.current_tweens[obj]):
done = tween.update(delta_seconds)
if done:
self... | [
"def",
"update",
"(",
"self",
",",
"delta_seconds",
")",
":",
"for",
"obj",
"in",
"tuple",
"(",
"self",
".",
"current_tweens",
")",
":",
"for",
"tween",
"in",
"tuple",
"(",
"self",
".",
"current_tweens",
"[",
"obj",
"]",
")",
":",
"done",
"=",
"tween... | update tweeners. delta_seconds is time in seconds since last frame | [
"update",
"tweeners",
".",
"delta_seconds",
"is",
"time",
"in",
"seconds",
"since",
"last",
"frame"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/pytweener.py#L97-L110 |
232,012 | projecthamster/hamster | src/hamster/lib/pytweener.py | Tween.update | def update(self, ptime):
"""Update tween with the time since the last frame"""
delta = self.delta + ptime
total_duration = self.delay + self.duration
if delta > total_duration:
delta = total_duration
if delta < self.delay:
pass
elif delta == tota... | python | def update(self, ptime):
"""Update tween with the time since the last frame"""
delta = self.delta + ptime
total_duration = self.delay + self.duration
if delta > total_duration:
delta = total_duration
if delta < self.delay:
pass
elif delta == tota... | [
"def",
"update",
"(",
"self",
",",
"ptime",
")",
":",
"delta",
"=",
"self",
".",
"delta",
"+",
"ptime",
"total_duration",
"=",
"self",
".",
"delay",
"+",
"self",
".",
"duration",
"if",
"delta",
">",
"total_duration",
":",
"delta",
"=",
"total_duration",
... | Update tween with the time since the last frame | [
"Update",
"tween",
"with",
"the",
"time",
"since",
"the",
"last",
"frame"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/pytweener.py#L154-L184 |
232,013 | projecthamster/hamster | src/hamster/overview.py | StackedBar.set_items | def set_items(self, items):
"""expects a list of key, value to work with"""
res = []
max_value = max(sum((rec[1] for rec in items)), 1)
for key, val in items:
res.append((key, val, val * 1.0 / max_value))
self._items = res | python | def set_items(self, items):
"""expects a list of key, value to work with"""
res = []
max_value = max(sum((rec[1] for rec in items)), 1)
for key, val in items:
res.append((key, val, val * 1.0 / max_value))
self._items = res | [
"def",
"set_items",
"(",
"self",
",",
"items",
")",
":",
"res",
"=",
"[",
"]",
"max_value",
"=",
"max",
"(",
"sum",
"(",
"(",
"rec",
"[",
"1",
"]",
"for",
"rec",
"in",
"items",
")",
")",
",",
"1",
")",
"for",
"key",
",",
"val",
"in",
"items",... | expects a list of key, value to work with | [
"expects",
"a",
"list",
"of",
"key",
"value",
"to",
"work",
"with"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/overview.py#L138-L144 |
232,014 | projecthamster/hamster | src/hamster/overview.py | HorizontalBarChart.set_values | def set_values(self, values):
"""expects a list of 2-tuples"""
self.values = values
self.height = len(self.values) * 14
self._max = max(rec[1] for rec in values) if values else dt.timedelta(0) | python | def set_values(self, values):
"""expects a list of 2-tuples"""
self.values = values
self.height = len(self.values) * 14
self._max = max(rec[1] for rec in values) if values else dt.timedelta(0) | [
"def",
"set_values",
"(",
"self",
",",
"values",
")",
":",
"self",
".",
"values",
"=",
"values",
"self",
".",
"height",
"=",
"len",
"(",
"self",
".",
"values",
")",
"*",
"14",
"self",
".",
"_max",
"=",
"max",
"(",
"rec",
"[",
"1",
"]",
"for",
"... | expects a list of 2-tuples | [
"expects",
"a",
"list",
"of",
"2",
"-",
"tuples"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/overview.py#L221-L225 |
232,015 | projecthamster/hamster | src/hamster/lib/stuff.py | datetime_to_hamsterday | def datetime_to_hamsterday(civil_date_time):
"""Return the hamster day corresponding to a given civil datetime.
The hamster day start is taken into account.
"""
# work around cyclic imports
from hamster.lib.configuration import conf
if civil_date_time.time() < conf.day_start:
# early ... | python | def datetime_to_hamsterday(civil_date_time):
"""Return the hamster day corresponding to a given civil datetime.
The hamster day start is taken into account.
"""
# work around cyclic imports
from hamster.lib.configuration import conf
if civil_date_time.time() < conf.day_start:
# early ... | [
"def",
"datetime_to_hamsterday",
"(",
"civil_date_time",
")",
":",
"# work around cyclic imports",
"from",
"hamster",
".",
"lib",
".",
"configuration",
"import",
"conf",
"if",
"civil_date_time",
".",
"time",
"(",
")",
"<",
"conf",
".",
"day_start",
":",
"# early m... | Return the hamster day corresponding to a given civil datetime.
The hamster day start is taken into account. | [
"Return",
"the",
"hamster",
"day",
"corresponding",
"to",
"a",
"given",
"civil",
"datetime",
"."
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/stuff.py#L43-L59 |
232,016 | projecthamster/hamster | src/hamster/lib/stuff.py | hamsterday_time_to_datetime | def hamsterday_time_to_datetime(hamsterday, time):
"""Return the civil datetime corresponding to a given hamster day and time.
The hamster day start is taken into account.
"""
# work around cyclic imports
from hamster.lib.configuration import conf
if time < conf.day_start:
# early mor... | python | def hamsterday_time_to_datetime(hamsterday, time):
"""Return the civil datetime corresponding to a given hamster day and time.
The hamster day start is taken into account.
"""
# work around cyclic imports
from hamster.lib.configuration import conf
if time < conf.day_start:
# early mor... | [
"def",
"hamsterday_time_to_datetime",
"(",
"hamsterday",
",",
"time",
")",
":",
"# work around cyclic imports",
"from",
"hamster",
".",
"lib",
".",
"configuration",
"import",
"conf",
"if",
"time",
"<",
"conf",
".",
"day_start",
":",
"# early morning, between midnight ... | Return the civil datetime corresponding to a given hamster day and time.
The hamster day start is taken into account. | [
"Return",
"the",
"civil",
"datetime",
"corresponding",
"to",
"a",
"given",
"hamster",
"day",
"and",
"time",
"."
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/stuff.py#L67-L82 |
232,017 | projecthamster/hamster | src/hamster/lib/stuff.py | format_duration | def format_duration(minutes, human = True):
"""formats duration in a human readable format.
accepts either minutes or timedelta"""
if isinstance(minutes, dt.timedelta):
minutes = duration_minutes(minutes)
if not minutes:
if human:
return ""
else:
return ... | python | def format_duration(minutes, human = True):
"""formats duration in a human readable format.
accepts either minutes or timedelta"""
if isinstance(minutes, dt.timedelta):
minutes = duration_minutes(minutes)
if not minutes:
if human:
return ""
else:
return ... | [
"def",
"format_duration",
"(",
"minutes",
",",
"human",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"minutes",
",",
"dt",
".",
"timedelta",
")",
":",
"minutes",
"=",
"duration_minutes",
"(",
"minutes",
")",
"if",
"not",
"minutes",
":",
"if",
"human",... | formats duration in a human readable format.
accepts either minutes or timedelta | [
"formats",
"duration",
"in",
"a",
"human",
"readable",
"format",
".",
"accepts",
"either",
"minutes",
"or",
"timedelta"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/stuff.py#L85-L121 |
232,018 | projecthamster/hamster | src/hamster/lib/stuff.py | duration_minutes | def duration_minutes(duration):
"""returns minutes from duration, otherwise we keep bashing in same math"""
if isinstance(duration, list):
res = dt.timedelta()
for entry in duration:
res += entry
return duration_minutes(res)
elif isinstance(duration, dt.timedelta):
... | python | def duration_minutes(duration):
"""returns minutes from duration, otherwise we keep bashing in same math"""
if isinstance(duration, list):
res = dt.timedelta()
for entry in duration:
res += entry
return duration_minutes(res)
elif isinstance(duration, dt.timedelta):
... | [
"def",
"duration_minutes",
"(",
"duration",
")",
":",
"if",
"isinstance",
"(",
"duration",
",",
"list",
")",
":",
"res",
"=",
"dt",
".",
"timedelta",
"(",
")",
"for",
"entry",
"in",
"duration",
":",
"res",
"+=",
"entry",
"return",
"duration_minutes",
"("... | returns minutes from duration, otherwise we keep bashing in same math | [
"returns",
"minutes",
"from",
"duration",
"otherwise",
"we",
"keep",
"bashing",
"in",
"same",
"math"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/stuff.py#L172-L183 |
232,019 | projecthamster/hamster | src/hamster/lib/stuff.py | locale_first_weekday | def locale_first_weekday():
"""figure if week starts on monday or sunday"""
first_weekday = 6 #by default settle on monday
try:
process = os.popen("locale first_weekday week-1stday")
week_offset, week_start = process.read().split('\n')[:2]
process.close()
week_start = dt.dat... | python | def locale_first_weekday():
"""figure if week starts on monday or sunday"""
first_weekday = 6 #by default settle on monday
try:
process = os.popen("locale first_weekday week-1stday")
week_offset, week_start = process.read().split('\n')[:2]
process.close()
week_start = dt.dat... | [
"def",
"locale_first_weekday",
"(",
")",
":",
"first_weekday",
"=",
"6",
"#by default settle on monday",
"try",
":",
"process",
"=",
"os",
".",
"popen",
"(",
"\"locale first_weekday week-1stday\"",
")",
"week_offset",
",",
"week_start",
"=",
"process",
".",
"read",
... | figure if week starts on monday or sunday | [
"figure",
"if",
"week",
"starts",
"on",
"monday",
"or",
"sunday"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/stuff.py#L206-L221 |
232,020 | projecthamster/hamster | src/hamster/lib/stuff.py | totals | def totals(iter, keyfunc, sumfunc):
"""groups items by field described in keyfunc and counts totals using value
from sumfunc
"""
data = sorted(iter, key=keyfunc)
res = {}
for k, group in groupby(data, keyfunc):
res[k] = sum([sumfunc(entry) for entry in group])
return res | python | def totals(iter, keyfunc, sumfunc):
"""groups items by field described in keyfunc and counts totals using value
from sumfunc
"""
data = sorted(iter, key=keyfunc)
res = {}
for k, group in groupby(data, keyfunc):
res[k] = sum([sumfunc(entry) for entry in group])
return res | [
"def",
"totals",
"(",
"iter",
",",
"keyfunc",
",",
"sumfunc",
")",
":",
"data",
"=",
"sorted",
"(",
"iter",
",",
"key",
"=",
"keyfunc",
")",
"res",
"=",
"{",
"}",
"for",
"k",
",",
"group",
"in",
"groupby",
"(",
"data",
",",
"keyfunc",
")",
":",
... | groups items by field described in keyfunc and counts totals using value
from sumfunc | [
"groups",
"items",
"by",
"field",
"described",
"in",
"keyfunc",
"and",
"counts",
"totals",
"using",
"value",
"from",
"sumfunc"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/stuff.py#L224-L234 |
232,021 | projecthamster/hamster | src/hamster/lib/stuff.py | dateDict | def dateDict(date, prefix = ""):
"""converts date into dictionary, having prefix for all the keys"""
res = {}
res[prefix+"a"] = date.strftime("%a")
res[prefix+"A"] = date.strftime("%A")
res[prefix+"b"] = date.strftime("%b")
res[prefix+"B"] = date.strftime("%B")
res[prefix+"c"] = date.strfti... | python | def dateDict(date, prefix = ""):
"""converts date into dictionary, having prefix for all the keys"""
res = {}
res[prefix+"a"] = date.strftime("%a")
res[prefix+"A"] = date.strftime("%A")
res[prefix+"b"] = date.strftime("%b")
res[prefix+"B"] = date.strftime("%B")
res[prefix+"c"] = date.strfti... | [
"def",
"dateDict",
"(",
"date",
",",
"prefix",
"=",
"\"\"",
")",
":",
"res",
"=",
"{",
"}",
"res",
"[",
"prefix",
"+",
"\"a\"",
"]",
"=",
"date",
".",
"strftime",
"(",
"\"%a\"",
")",
"res",
"[",
"prefix",
"+",
"\"A\"",
"]",
"=",
"date",
".",
"s... | converts date into dictionary, having prefix for all the keys | [
"converts",
"date",
"into",
"dictionary",
"having",
"prefix",
"for",
"all",
"the",
"keys"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/stuff.py#L237-L266 |
232,022 | projecthamster/hamster | src/hamster/storage/db.py | Storage.__get_tag_ids | def __get_tag_ids(self, tags):
"""look up tags by their name. create if not found"""
db_tags = self.fetchall("select * from tags where name in (%s)"
% ",".join(["?"] * len(tags)), tags) # bit of magic here - using sqlites bind variables
changes = Fal... | python | def __get_tag_ids(self, tags):
"""look up tags by their name. create if not found"""
db_tags = self.fetchall("select * from tags where name in (%s)"
% ",".join(["?"] * len(tags)), tags) # bit of magic here - using sqlites bind variables
changes = Fal... | [
"def",
"__get_tag_ids",
"(",
"self",
",",
"tags",
")",
":",
"db_tags",
"=",
"self",
".",
"fetchall",
"(",
"\"select * from tags where name in (%s)\"",
"%",
"\",\"",
".",
"join",
"(",
"[",
"\"?\"",
"]",
"*",
"len",
"(",
"tags",
")",
")",
",",
"tags",
")",... | look up tags by their name. create if not found | [
"look",
"up",
"tags",
"by",
"their",
"name",
".",
"create",
"if",
"not",
"found"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/storage/db.py#L161-L186 |
232,023 | projecthamster/hamster | src/hamster/storage/db.py | Storage.__get_activity_by_name | def __get_activity_by_name(self, name, category_id = None, resurrect = True):
"""get most recent, preferably not deleted activity by it's name"""
if category_id:
query = """
SELECT a.id, a.name, a.deleted, coalesce(b.name, ?) as category
FROM ... | python | def __get_activity_by_name(self, name, category_id = None, resurrect = True):
"""get most recent, preferably not deleted activity by it's name"""
if category_id:
query = """
SELECT a.id, a.name, a.deleted, coalesce(b.name, ?) as category
FROM ... | [
"def",
"__get_activity_by_name",
"(",
"self",
",",
"name",
",",
"category_id",
"=",
"None",
",",
"resurrect",
"=",
"True",
")",
":",
"if",
"category_id",
":",
"query",
"=",
"\"\"\"\n SELECT a.id, a.name, a.deleted, coalesce(b.name, ?) as category\n ... | get most recent, preferably not deleted activity by it's name | [
"get",
"most",
"recent",
"preferably",
"not",
"deleted",
"activity",
"by",
"it",
"s",
"name"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/storage/db.py#L297-L340 |
232,024 | projecthamster/hamster | src/hamster/storage/db.py | Storage.__get_category_id | def __get_category_id(self, name):
"""returns category by it's name"""
query = """
SELECT id from categories
WHERE lower(name) = lower(?)
ORDER BY id desc
LIMIT 1
"""
res = self.fetchone(query, (name, ))
... | python | def __get_category_id(self, name):
"""returns category by it's name"""
query = """
SELECT id from categories
WHERE lower(name) = lower(?)
ORDER BY id desc
LIMIT 1
"""
res = self.fetchone(query, (name, ))
... | [
"def",
"__get_category_id",
"(",
"self",
",",
"name",
")",
":",
"query",
"=",
"\"\"\"\n SELECT id from categories\n WHERE lower(name) = lower(?)\n ORDER BY id desc\n LIMIT 1\n \"\"\"",
"res",
"=",
"self",
".",... | returns category by it's name | [
"returns",
"category",
"by",
"it",
"s",
"name"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/storage/db.py#L342-L357 |
232,025 | projecthamster/hamster | src/hamster/storage/db.py | Storage.__group_tags | def __group_tags(self, facts):
"""put the fact back together and move all the unique tags to an array"""
if not facts: return facts #be it None or whatever
grouped_facts = []
for fact_id, fact_tags in itertools.groupby(facts, lambda f: f["id"]):
fact_tags = list(fact_tags)
... | python | def __group_tags(self, facts):
"""put the fact back together and move all the unique tags to an array"""
if not facts: return facts #be it None or whatever
grouped_facts = []
for fact_id, fact_tags in itertools.groupby(facts, lambda f: f["id"]):
fact_tags = list(fact_tags)
... | [
"def",
"__group_tags",
"(",
"self",
",",
"facts",
")",
":",
"if",
"not",
"facts",
":",
"return",
"facts",
"#be it None or whatever",
"grouped_facts",
"=",
"[",
"]",
"for",
"fact_id",
",",
"fact_tags",
"in",
"itertools",
".",
"groupby",
"(",
"facts",
",",
"... | put the fact back together and move all the unique tags to an array | [
"put",
"the",
"fact",
"back",
"together",
"and",
"move",
"all",
"the",
"unique",
"tags",
"to",
"an",
"array"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/storage/db.py#L379-L398 |
232,026 | projecthamster/hamster | src/hamster/storage/db.py | Storage.__squeeze_in | def __squeeze_in(self, start_time):
""" tries to put task in the given date
if there are conflicts, we will only truncate the ongoing task
and replace it's end part with our activity """
# we are checking if our start time is in the middle of anything
# or maybe there is... | python | def __squeeze_in(self, start_time):
""" tries to put task in the given date
if there are conflicts, we will only truncate the ongoing task
and replace it's end part with our activity """
# we are checking if our start time is in the middle of anything
# or maybe there is... | [
"def",
"__squeeze_in",
"(",
"self",
",",
"start_time",
")",
":",
"# we are checking if our start time is in the middle of anything",
"# or maybe there is something after us - so we know to adjust end time",
"# in the latter case go only few hours ahead. everything else is madness, heh",
"query... | tries to put task in the given date
if there are conflicts, we will only truncate the ongoing task
and replace it's end part with our activity | [
"tries",
"to",
"put",
"task",
"in",
"the",
"given",
"date",
"if",
"there",
"are",
"conflicts",
"we",
"will",
"only",
"truncate",
"the",
"ongoing",
"task",
"and",
"replace",
"it",
"s",
"end",
"part",
"with",
"our",
"activity"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/storage/db.py#L415-L447 |
232,027 | projecthamster/hamster | src/hamster/storage/db.py | Storage.__get_activities | def __get_activities(self, search):
"""returns list of activities for autocomplete,
activity names converted to lowercase"""
query = """
SELECT a.name AS name, b.name AS category
FROM activities a
LEFT JOIN categories b ON coalesce(b.id... | python | def __get_activities(self, search):
"""returns list of activities for autocomplete,
activity names converted to lowercase"""
query = """
SELECT a.name AS name, b.name AS category
FROM activities a
LEFT JOIN categories b ON coalesce(b.id... | [
"def",
"__get_activities",
"(",
"self",
",",
"search",
")",
":",
"query",
"=",
"\"\"\"\n SELECT a.name AS name, b.name AS category\n FROM activities a\n LEFT JOIN categories b ON coalesce(b.id, -1) = a.category_id\n LEFT JOIN fa... | returns list of activities for autocomplete,
activity names converted to lowercase | [
"returns",
"list",
"of",
"activities",
"for",
"autocomplete",
"activity",
"names",
"converted",
"to",
"lowercase"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/storage/db.py#L760-L779 |
232,028 | projecthamster/hamster | src/hamster/storage/db.py | Storage.__remove_activity | def __remove_activity(self, id):
""" check if we have any facts with this activity and behave accordingly
if there are facts - sets activity to deleted = True
else, just remove it"""
query = "select count(*) as count from facts where activity_id = ?"
bound_facts = self.f... | python | def __remove_activity(self, id):
""" check if we have any facts with this activity and behave accordingly
if there are facts - sets activity to deleted = True
else, just remove it"""
query = "select count(*) as count from facts where activity_id = ?"
bound_facts = self.f... | [
"def",
"__remove_activity",
"(",
"self",
",",
"id",
")",
":",
"query",
"=",
"\"select count(*) as count from facts where activity_id = ?\"",
"bound_facts",
"=",
"self",
".",
"fetchone",
"(",
"query",
",",
"(",
"id",
",",
")",
")",
"[",
"'count'",
"]",
"if",
"b... | check if we have any facts with this activity and behave accordingly
if there are facts - sets activity to deleted = True
else, just remove it | [
"check",
"if",
"we",
"have",
"any",
"facts",
"with",
"this",
"activity",
"and",
"behave",
"accordingly",
"if",
"there",
"are",
"facts",
"-",
"sets",
"activity",
"to",
"deleted",
"=",
"True",
"else",
"just",
"remove",
"it"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/storage/db.py#L781-L792 |
232,029 | projecthamster/hamster | src/hamster/storage/db.py | Storage.__remove_category | def __remove_category(self, id):
"""move all activities to unsorted and remove category"""
affected_query = """
SELECT id
FROM facts
WHERE activity_id in (SELECT id FROM activities where category_id=?)
"""
affected_ids = [res[0] for res in self.fet... | python | def __remove_category(self, id):
"""move all activities to unsorted and remove category"""
affected_query = """
SELECT id
FROM facts
WHERE activity_id in (SELECT id FROM activities where category_id=?)
"""
affected_ids = [res[0] for res in self.fet... | [
"def",
"__remove_category",
"(",
"self",
",",
"id",
")",
":",
"affected_query",
"=",
"\"\"\"\n SELECT id\n FROM facts\n WHERE activity_id in (SELECT id FROM activities where category_id=?)\n \"\"\"",
"affected_ids",
"=",
"[",
"res",
"[",
"0"... | move all activities to unsorted and remove category | [
"move",
"all",
"activities",
"to",
"unsorted",
"and",
"remove",
"category"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/storage/db.py#L795-L810 |
232,030 | projecthamster/hamster | src/hamster/storage/db.py | Storage.__remove_index | def __remove_index(self, ids):
"""remove affected ids from the index"""
if not ids:
return
ids = ",".join((str(id) for id in ids))
self.execute("DELETE FROM fact_index where id in (%s)" % ids) | python | def __remove_index(self, ids):
"""remove affected ids from the index"""
if not ids:
return
ids = ",".join((str(id) for id in ids))
self.execute("DELETE FROM fact_index where id in (%s)" % ids) | [
"def",
"__remove_index",
"(",
"self",
",",
"ids",
")",
":",
"if",
"not",
"ids",
":",
"return",
"ids",
"=",
"\",\"",
".",
"join",
"(",
"(",
"str",
"(",
"id",
")",
"for",
"id",
"in",
"ids",
")",
")",
"self",
".",
"execute",
"(",
"\"DELETE FROM fact_i... | remove affected ids from the index | [
"remove",
"affected",
"ids",
"from",
"the",
"index"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/storage/db.py#L834-L840 |
232,031 | projecthamster/hamster | src/hamster/storage/db.py | Storage.execute | def execute(self, statement, params = ()):
"""
execute sql statement. optionally you can give multiple statements
to save on cursor creation and closure
"""
con = self.__con or self.connection
cur = self.__cur or con.cursor()
if isinstance(statement, list) == Fal... | python | def execute(self, statement, params = ()):
"""
execute sql statement. optionally you can give multiple statements
to save on cursor creation and closure
"""
con = self.__con or self.connection
cur = self.__cur or con.cursor()
if isinstance(statement, list) == Fal... | [
"def",
"execute",
"(",
"self",
",",
"statement",
",",
"params",
"=",
"(",
")",
")",
":",
"con",
"=",
"self",
".",
"__con",
"or",
"self",
".",
"connection",
"cur",
"=",
"self",
".",
"__cur",
"or",
"con",
".",
"cursor",
"(",
")",
"if",
"isinstance",
... | execute sql statement. optionally you can give multiple statements
to save on cursor creation and closure | [
"execute",
"sql",
"statement",
".",
"optionally",
"you",
"can",
"give",
"multiple",
"statements",
"to",
"save",
"on",
"cursor",
"creation",
"and",
"closure"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/storage/db.py#L913-L932 |
232,032 | projecthamster/hamster | src/hamster/storage/db.py | Storage.run_fixtures | def run_fixtures(self):
self.start_transaction()
"""upgrade DB to hamster version"""
version = self.fetchone("SELECT version FROM version")["version"]
current_version = 9
if version < 8:
# working around sqlite's utf-f case sensitivity (bug 624438)
# mor... | python | def run_fixtures(self):
self.start_transaction()
"""upgrade DB to hamster version"""
version = self.fetchone("SELECT version FROM version")["version"]
current_version = 9
if version < 8:
# working around sqlite's utf-f case sensitivity (bug 624438)
# mor... | [
"def",
"run_fixtures",
"(",
"self",
")",
":",
"self",
".",
"start_transaction",
"(",
")",
"version",
"=",
"self",
".",
"fetchone",
"(",
"\"SELECT version FROM version\"",
")",
"[",
"\"version\"",
"]",
"current_version",
"=",
"9",
"if",
"version",
"<",
"8",
"... | upgrade DB to hamster version | [
"upgrade",
"DB",
"to",
"hamster",
"version"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/storage/db.py#L959-L995 |
232,033 | projecthamster/hamster | src/hamster/widgets/facttree.py | FactTree.current_fact_index | def current_fact_index(self):
"""Current fact index in the self.facts list."""
facts_ids = [fact.id for fact in self.facts]
return facts_ids.index(self.current_fact.id) | python | def current_fact_index(self):
"""Current fact index in the self.facts list."""
facts_ids = [fact.id for fact in self.facts]
return facts_ids.index(self.current_fact.id) | [
"def",
"current_fact_index",
"(",
"self",
")",
":",
"facts_ids",
"=",
"[",
"fact",
".",
"id",
"for",
"fact",
"in",
"self",
".",
"facts",
"]",
"return",
"facts_ids",
".",
"index",
"(",
"self",
".",
"current_fact",
".",
"id",
")"
] | Current fact index in the self.facts list. | [
"Current",
"fact",
"index",
"in",
"the",
"self",
".",
"facts",
"list",
"."
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/widgets/facttree.py#L258-L261 |
232,034 | projecthamster/hamster | src/hamster/lib/graphics.py | chain | def chain(*steps):
"""chains the given list of functions and object animations into a callback string.
Expects an interlaced list of object and params, something like:
object, {params},
callable, {params},
object, {},
object, {params}
Assumes that all cal... | python | def chain(*steps):
"""chains the given list of functions and object animations into a callback string.
Expects an interlaced list of object and params, something like:
object, {params},
callable, {params},
object, {},
object, {params}
Assumes that all cal... | [
"def",
"chain",
"(",
"*",
"steps",
")",
":",
"if",
"not",
"steps",
":",
"return",
"def",
"on_done",
"(",
"sprite",
"=",
"None",
")",
":",
"chain",
"(",
"*",
"steps",
"[",
"2",
":",
"]",
")",
"obj",
",",
"params",
"=",
"steps",
"[",
":",
"2",
... | chains the given list of functions and object animations into a callback string.
Expects an interlaced list of object and params, something like:
object, {params},
callable, {params},
object, {},
object, {params}
Assumes that all callees accept on_complete na... | [
"chains",
"the",
"given",
"list",
"of",
"functions",
"and",
"object",
"animations",
"into",
"a",
"callback",
"string",
"."
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L160-L185 |
232,035 | projecthamster/hamster | src/hamster/lib/graphics.py | full_pixels | def full_pixels(space, data, gap_pixels=1):
"""returns the given data distributed in the space ensuring it's full pixels
and with the given gap.
this will result in minor sub-pixel inaccuracies.
XXX - figure out where to place these guys as they are quite useful
"""
available = space - (len(data... | python | def full_pixels(space, data, gap_pixels=1):
"""returns the given data distributed in the space ensuring it's full pixels
and with the given gap.
this will result in minor sub-pixel inaccuracies.
XXX - figure out where to place these guys as they are quite useful
"""
available = space - (len(data... | [
"def",
"full_pixels",
"(",
"space",
",",
"data",
",",
"gap_pixels",
"=",
"1",
")",
":",
"available",
"=",
"space",
"-",
"(",
"len",
"(",
"data",
")",
"-",
"1",
")",
"*",
"gap_pixels",
"# 8 recs 7 gaps",
"res",
"=",
"[",
"]",
"for",
"i",
",",
"val",... | returns the given data distributed in the space ensuring it's full pixels
and with the given gap.
this will result in minor sub-pixel inaccuracies.
XXX - figure out where to place these guys as they are quite useful | [
"returns",
"the",
"given",
"data",
"distributed",
"in",
"the",
"space",
"ensuring",
"it",
"s",
"full",
"pixels",
"and",
"with",
"the",
"given",
"gap",
".",
"this",
"will",
"result",
"in",
"minor",
"sub",
"-",
"pixel",
"inaccuracies",
".",
"XXX",
"-",
"fi... | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L187-L205 |
232,036 | projecthamster/hamster | src/hamster/lib/graphics.py | ColorUtils.gdk | def gdk(self, color):
"""returns gdk.Color object of the given color"""
c = self.parse(color)
return gdk.Color.from_floats(c) | python | def gdk(self, color):
"""returns gdk.Color object of the given color"""
c = self.parse(color)
return gdk.Color.from_floats(c) | [
"def",
"gdk",
"(",
"self",
",",
"color",
")",
":",
"c",
"=",
"self",
".",
"parse",
"(",
"color",
")",
"return",
"gdk",
".",
"Color",
".",
"from_floats",
"(",
"c",
")"
] | returns gdk.Color object of the given color | [
"returns",
"gdk",
".",
"Color",
"object",
"of",
"the",
"given",
"color"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L95-L98 |
232,037 | projecthamster/hamster | src/hamster/lib/graphics.py | ColorUtils.contrast | def contrast(self, color, step):
"""if color is dark, will return a lighter one, otherwise darker"""
hls = colorsys.rgb_to_hls(*self.rgb(color))
if self.is_light(color):
return colorsys.hls_to_rgb(hls[0], hls[1] - step, hls[2])
else:
return colorsys.hls_to_rgb(hls... | python | def contrast(self, color, step):
"""if color is dark, will return a lighter one, otherwise darker"""
hls = colorsys.rgb_to_hls(*self.rgb(color))
if self.is_light(color):
return colorsys.hls_to_rgb(hls[0], hls[1] - step, hls[2])
else:
return colorsys.hls_to_rgb(hls... | [
"def",
"contrast",
"(",
"self",
",",
"color",
",",
"step",
")",
":",
"hls",
"=",
"colorsys",
".",
"rgb_to_hls",
"(",
"*",
"self",
".",
"rgb",
"(",
"color",
")",
")",
"if",
"self",
".",
"is_light",
"(",
"color",
")",
":",
"return",
"colorsys",
".",
... | if color is dark, will return a lighter one, otherwise darker | [
"if",
"color",
"is",
"dark",
"will",
"return",
"a",
"lighter",
"one",
"otherwise",
"darker"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L121-L127 |
232,038 | projecthamster/hamster | src/hamster/lib/graphics.py | ColorUtils.mix | def mix(self, ca, cb, xb):
"""Mix colors.
Args:
ca (gdk.RGBA): first color
cb (gdk.RGBA): second color
xb (float): between 0.0 and 1.0
Return:
gdk.RGBA: linear interpolation between ca and cb,
0 or 1 return the unaltered 1st... | python | def mix(self, ca, cb, xb):
"""Mix colors.
Args:
ca (gdk.RGBA): first color
cb (gdk.RGBA): second color
xb (float): between 0.0 and 1.0
Return:
gdk.RGBA: linear interpolation between ca and cb,
0 or 1 return the unaltered 1st... | [
"def",
"mix",
"(",
"self",
",",
"ca",
",",
"cb",
",",
"xb",
")",
":",
"r",
"=",
"(",
"1",
"-",
"xb",
")",
"*",
"ca",
".",
"red",
"+",
"xb",
"*",
"cb",
".",
"red",
"g",
"=",
"(",
"1",
"-",
"xb",
")",
"*",
"ca",
".",
"green",
"+",
"xb",... | Mix colors.
Args:
ca (gdk.RGBA): first color
cb (gdk.RGBA): second color
xb (float): between 0.0 and 1.0
Return:
gdk.RGBA: linear interpolation between ca and cb,
0 or 1 return the unaltered 1st or 2nd color respectively,
... | [
"Mix",
"colors",
"."
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L130-L147 |
232,039 | projecthamster/hamster | src/hamster/lib/graphics.py | Graphics.set_line_style | def set_line_style(self, width = None, dash = None, dash_offset = 0):
"""change width and dash of a line"""
if width is not None:
self._add_instruction("set_line_width", width)
if dash is not None:
self._add_instruction("set_dash", dash, dash_offset) | python | def set_line_style(self, width = None, dash = None, dash_offset = 0):
"""change width and dash of a line"""
if width is not None:
self._add_instruction("set_line_width", width)
if dash is not None:
self._add_instruction("set_dash", dash, dash_offset) | [
"def",
"set_line_style",
"(",
"self",
",",
"width",
"=",
"None",
",",
"dash",
"=",
"None",
",",
"dash_offset",
"=",
"0",
")",
":",
"if",
"width",
"is",
"not",
"None",
":",
"self",
".",
"_add_instruction",
"(",
"\"set_line_width\"",
",",
"width",
")",
"... | change width and dash of a line | [
"change",
"width",
"and",
"dash",
"of",
"a",
"line"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L328-L334 |
232,040 | projecthamster/hamster | src/hamster/lib/graphics.py | Graphics._set_color | def _set_color(self, context, r, g, b, a):
"""the alpha has to changed based on the parent, so that happens at the
time of drawing"""
if a < 1:
context.set_source_rgba(r, g, b, a)
else:
context.set_source_rgb(r, g, b) | python | def _set_color(self, context, r, g, b, a):
"""the alpha has to changed based on the parent, so that happens at the
time of drawing"""
if a < 1:
context.set_source_rgba(r, g, b, a)
else:
context.set_source_rgb(r, g, b) | [
"def",
"_set_color",
"(",
"self",
",",
"context",
",",
"r",
",",
"g",
",",
"b",
",",
"a",
")",
":",
"if",
"a",
"<",
"1",
":",
"context",
".",
"set_source_rgba",
"(",
"r",
",",
"g",
",",
"b",
",",
"a",
")",
"else",
":",
"context",
".",
"set_so... | the alpha has to changed based on the parent, so that happens at the
time of drawing | [
"the",
"alpha",
"has",
"to",
"changed",
"based",
"on",
"the",
"parent",
"so",
"that",
"happens",
"at",
"the",
"time",
"of",
"drawing"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L338-L344 |
232,041 | projecthamster/hamster | src/hamster/lib/graphics.py | Graphics.arc | def arc(self, x, y, radius, start_angle, end_angle):
"""draw arc going counter-clockwise from start_angle to end_angle"""
self._add_instruction("arc", x, y, radius, start_angle, end_angle) | python | def arc(self, x, y, radius, start_angle, end_angle):
"""draw arc going counter-clockwise from start_angle to end_angle"""
self._add_instruction("arc", x, y, radius, start_angle, end_angle) | [
"def",
"arc",
"(",
"self",
",",
"x",
",",
"y",
",",
"radius",
",",
"start_angle",
",",
"end_angle",
")",
":",
"self",
".",
"_add_instruction",
"(",
"\"arc\"",
",",
"x",
",",
"y",
",",
"radius",
",",
"start_angle",
",",
"end_angle",
")"
] | draw arc going counter-clockwise from start_angle to end_angle | [
"draw",
"arc",
"going",
"counter",
"-",
"clockwise",
"from",
"start_angle",
"to",
"end_angle"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L360-L362 |
232,042 | projecthamster/hamster | src/hamster/lib/graphics.py | Graphics.ellipse | def ellipse(self, x, y, width, height, edges = None):
"""draw 'perfect' ellipse, opposed to squashed circle. works also for
equilateral polygons"""
# the automatic edge case is somewhat arbitrary
steps = edges or max((32, width, height)) / 2
angle = 0
step = math.pi *... | python | def ellipse(self, x, y, width, height, edges = None):
"""draw 'perfect' ellipse, opposed to squashed circle. works also for
equilateral polygons"""
# the automatic edge case is somewhat arbitrary
steps = edges or max((32, width, height)) / 2
angle = 0
step = math.pi *... | [
"def",
"ellipse",
"(",
"self",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
",",
"edges",
"=",
"None",
")",
":",
"# the automatic edge case is somewhat arbitrary",
"steps",
"=",
"edges",
"or",
"max",
"(",
"(",
"32",
",",
"width",
",",
"height",
")",
... | draw 'perfect' ellipse, opposed to squashed circle. works also for
equilateral polygons | [
"draw",
"perfect",
"ellipse",
"opposed",
"to",
"squashed",
"circle",
".",
"works",
"also",
"for",
"equilateral",
"polygons"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L368-L388 |
232,043 | projecthamster/hamster | src/hamster/lib/graphics.py | Graphics.arc_negative | def arc_negative(self, x, y, radius, start_angle, end_angle):
"""draw arc going clockwise from start_angle to end_angle"""
self._add_instruction("arc_negative", x, y, radius, start_angle, end_angle) | python | def arc_negative(self, x, y, radius, start_angle, end_angle):
"""draw arc going clockwise from start_angle to end_angle"""
self._add_instruction("arc_negative", x, y, radius, start_angle, end_angle) | [
"def",
"arc_negative",
"(",
"self",
",",
"x",
",",
"y",
",",
"radius",
",",
"start_angle",
",",
"end_angle",
")",
":",
"self",
".",
"_add_instruction",
"(",
"\"arc_negative\"",
",",
"x",
",",
"y",
",",
"radius",
",",
"start_angle",
",",
"end_angle",
")"
... | draw arc going clockwise from start_angle to end_angle | [
"draw",
"arc",
"going",
"clockwise",
"from",
"start_angle",
"to",
"end_angle"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L390-L392 |
232,044 | projecthamster/hamster | src/hamster/lib/graphics.py | Graphics.rectangle | def rectangle(self, x, y, width, height, corner_radius = 0):
"""draw a rectangle. if corner_radius is specified, will draw
rounded corners. corner_radius can be either a number or a tuple of
four items to specify individually each corner, starting from top-left
and going clockwise"""
... | python | def rectangle(self, x, y, width, height, corner_radius = 0):
"""draw a rectangle. if corner_radius is specified, will draw
rounded corners. corner_radius can be either a number or a tuple of
four items to specify individually each corner, starting from top-left
and going clockwise"""
... | [
"def",
"rectangle",
"(",
"self",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
",",
"corner_radius",
"=",
"0",
")",
":",
"if",
"corner_radius",
"<=",
"0",
":",
"self",
".",
"_add_instruction",
"(",
"\"rectangle\"",
",",
"x",
",",
"y",
",",
"width"... | draw a rectangle. if corner_radius is specified, will draw
rounded corners. corner_radius can be either a number or a tuple of
four items to specify individually each corner, starting from top-left
and going clockwise | [
"draw",
"a",
"rectangle",
".",
"if",
"corner_radius",
"is",
"specified",
"will",
"draw",
"rounded",
"corners",
".",
"corner_radius",
"can",
"be",
"either",
"a",
"number",
"or",
"a",
"tuple",
"of",
"four",
"items",
"to",
"specify",
"individually",
"each",
"co... | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L400-L415 |
232,045 | projecthamster/hamster | src/hamster/lib/graphics.py | Graphics.fill_area | def fill_area(self, x, y, width, height, color, opacity = 1):
"""fill rectangular area with specified color"""
self.save_context()
self.rectangle(x, y, width, height)
self._add_instruction("clip")
self.rectangle(x, y, width, height)
self.fill(color, opacity)
self.... | python | def fill_area(self, x, y, width, height, color, opacity = 1):
"""fill rectangular area with specified color"""
self.save_context()
self.rectangle(x, y, width, height)
self._add_instruction("clip")
self.rectangle(x, y, width, height)
self.fill(color, opacity)
self.... | [
"def",
"fill_area",
"(",
"self",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
",",
"color",
",",
"opacity",
"=",
"1",
")",
":",
"self",
".",
"save_context",
"(",
")",
"self",
".",
"rectangle",
"(",
"x",
",",
"y",
",",
"width",
",",
"height",
... | fill rectangular area with specified color | [
"fill",
"rectangular",
"area",
"with",
"specified",
"color"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L444-L451 |
232,046 | projecthamster/hamster | src/hamster/lib/graphics.py | Graphics.fill_stroke | def fill_stroke(self, fill = None, stroke = None, opacity = 1, line_width = None):
"""fill and stroke the drawn area in one go"""
if line_width: self.set_line_style(line_width)
if fill and stroke:
self.fill_preserve(fill, opacity)
elif fill:
self.fill(fill, opaci... | python | def fill_stroke(self, fill = None, stroke = None, opacity = 1, line_width = None):
"""fill and stroke the drawn area in one go"""
if line_width: self.set_line_style(line_width)
if fill and stroke:
self.fill_preserve(fill, opacity)
elif fill:
self.fill(fill, opaci... | [
"def",
"fill_stroke",
"(",
"self",
",",
"fill",
"=",
"None",
",",
"stroke",
"=",
"None",
",",
"opacity",
"=",
"1",
",",
"line_width",
"=",
"None",
")",
":",
"if",
"line_width",
":",
"self",
".",
"set_line_style",
"(",
"line_width",
")",
"if",
"fill",
... | fill and stroke the drawn area in one go | [
"fill",
"and",
"stroke",
"the",
"drawn",
"area",
"in",
"one",
"go"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L453-L463 |
232,047 | projecthamster/hamster | src/hamster/lib/graphics.py | Graphics.create_layout | def create_layout(self, size = None):
"""utility function to create layout with the default font. Size and
alignment parameters are shortcuts to according functions of the
pango.Layout"""
if not self.context:
# TODO - this is rather sloppy as far as exception goes
... | python | def create_layout(self, size = None):
"""utility function to create layout with the default font. Size and
alignment parameters are shortcuts to according functions of the
pango.Layout"""
if not self.context:
# TODO - this is rather sloppy as far as exception goes
... | [
"def",
"create_layout",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"context",
":",
"# TODO - this is rather sloppy as far as exception goes",
"# should explain better",
"raise",
"Exception",
"(",
"\"Can not create layout without existi... | utility function to create layout with the default font. Size and
alignment parameters are shortcuts to according functions of the
pango.Layout | [
"utility",
"function",
"to",
"create",
"layout",
"with",
"the",
"default",
"font",
".",
"Size",
"and",
"alignment",
"parameters",
"are",
"shortcuts",
"to",
"according",
"functions",
"of",
"the",
"pango",
".",
"Layout"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L465-L479 |
232,048 | projecthamster/hamster | src/hamster/lib/graphics.py | Graphics.show_label | def show_label(self, text, size = None, color = None, font_desc = None):
"""display text. unless font_desc is provided, will use system's default font"""
font_desc = pango.FontDescription(font_desc or _font_desc)
if color: self.set_color(color)
if size: font_desc.set_absolute_size(size *... | python | def show_label(self, text, size = None, color = None, font_desc = None):
"""display text. unless font_desc is provided, will use system's default font"""
font_desc = pango.FontDescription(font_desc or _font_desc)
if color: self.set_color(color)
if size: font_desc.set_absolute_size(size *... | [
"def",
"show_label",
"(",
"self",
",",
"text",
",",
"size",
"=",
"None",
",",
"color",
"=",
"None",
",",
"font_desc",
"=",
"None",
")",
":",
"font_desc",
"=",
"pango",
".",
"FontDescription",
"(",
"font_desc",
"or",
"_font_desc",
")",
"if",
"color",
":... | display text. unless font_desc is provided, will use system's default font | [
"display",
"text",
".",
"unless",
"font_desc",
"is",
"provided",
"will",
"use",
"system",
"s",
"default",
"font"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L481-L486 |
232,049 | projecthamster/hamster | src/hamster/lib/graphics.py | Graphics._draw | def _draw(self, context, opacity):
"""draw accumulated instructions in context"""
# if we have been moved around, we should update bounds
fresh_draw = len(self.__new_instructions or []) > 0
if fresh_draw: #new stuff!
self.paths = []
self.__instruction_cache = sel... | python | def _draw(self, context, opacity):
"""draw accumulated instructions in context"""
# if we have been moved around, we should update bounds
fresh_draw = len(self.__new_instructions or []) > 0
if fresh_draw: #new stuff!
self.paths = []
self.__instruction_cache = sel... | [
"def",
"_draw",
"(",
"self",
",",
"context",
",",
"opacity",
")",
":",
"# if we have been moved around, we should update bounds",
"fresh_draw",
"=",
"len",
"(",
"self",
".",
"__new_instructions",
"or",
"[",
"]",
")",
">",
"0",
"if",
"fresh_draw",
":",
"#new stuf... | draw accumulated instructions in context | [
"draw",
"accumulated",
"instructions",
"in",
"context"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L538-L566 |
232,050 | projecthamster/hamster | src/hamster/lib/graphics.py | Parent.find | def find(self, id):
"""breadth-first sprite search by ID"""
for sprite in self.sprites:
if sprite.id == id:
return sprite
for sprite in self.sprites:
found = sprite.find(id)
if found:
return found | python | def find(self, id):
"""breadth-first sprite search by ID"""
for sprite in self.sprites:
if sprite.id == id:
return sprite
for sprite in self.sprites:
found = sprite.find(id)
if found:
return found | [
"def",
"find",
"(",
"self",
",",
"id",
")",
":",
"for",
"sprite",
"in",
"self",
".",
"sprites",
":",
"if",
"sprite",
".",
"id",
"==",
"id",
":",
"return",
"sprite",
"for",
"sprite",
"in",
"self",
".",
"sprites",
":",
"found",
"=",
"sprite",
".",
... | breadth-first sprite search by ID | [
"breadth",
"-",
"first",
"sprite",
"search",
"by",
"ID"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L674-L683 |
232,051 | projecthamster/hamster | src/hamster/lib/graphics.py | Parent.traverse | def traverse(self, attr_name = None, attr_value = None):
"""traverse the whole sprite tree and return child sprites which have the
attribute and it's set to the specified value.
If falue is None, will return all sprites that have the attribute
"""
for sprite in self.sprites:
... | python | def traverse(self, attr_name = None, attr_value = None):
"""traverse the whole sprite tree and return child sprites which have the
attribute and it's set to the specified value.
If falue is None, will return all sprites that have the attribute
"""
for sprite in self.sprites:
... | [
"def",
"traverse",
"(",
"self",
",",
"attr_name",
"=",
"None",
",",
"attr_value",
"=",
"None",
")",
":",
"for",
"sprite",
"in",
"self",
".",
"sprites",
":",
"if",
"(",
"attr_name",
"is",
"None",
")",
"or",
"(",
"attr_value",
"is",
"None",
"and",
"has... | traverse the whole sprite tree and return child sprites which have the
attribute and it's set to the specified value.
If falue is None, will return all sprites that have the attribute | [
"traverse",
"the",
"whole",
"sprite",
"tree",
"and",
"return",
"child",
"sprites",
"which",
"have",
"the",
"attribute",
"and",
"it",
"s",
"set",
"to",
"the",
"specified",
"value",
".",
"If",
"falue",
"is",
"None",
"will",
"return",
"all",
"sprites",
"that"... | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L688-L700 |
232,052 | projecthamster/hamster | src/hamster/lib/graphics.py | Parent.log | def log(self, *lines):
"""will print out the lines in console if debug is enabled for the
specific sprite"""
if getattr(self, "debug", False):
print(dt.datetime.now().time(), end=' ')
for line in lines:
print(line, end=' ')
print() | python | def log(self, *lines):
"""will print out the lines in console if debug is enabled for the
specific sprite"""
if getattr(self, "debug", False):
print(dt.datetime.now().time(), end=' ')
for line in lines:
print(line, end=' ')
print() | [
"def",
"log",
"(",
"self",
",",
"*",
"lines",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"\"debug\"",
",",
"False",
")",
":",
"print",
"(",
"dt",
".",
"datetime",
".",
"now",
"(",
")",
".",
"time",
"(",
")",
",",
"end",
"=",
"' '",
")",
"fo... | will print out the lines in console if debug is enabled for the
specific sprite | [
"will",
"print",
"out",
"the",
"lines",
"in",
"console",
"if",
"debug",
"is",
"enabled",
"for",
"the",
"specific",
"sprite"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L702-L709 |
232,053 | projecthamster/hamster | src/hamster/lib/graphics.py | Parent._add | def _add(self, sprite, index = None):
"""add one sprite at a time. used by add_child. split them up so that
it would be possible specify the index externally"""
if sprite == self:
raise Exception("trying to add sprite to itself")
if sprite.parent:
sprite.x, sprit... | python | def _add(self, sprite, index = None):
"""add one sprite at a time. used by add_child. split them up so that
it would be possible specify the index externally"""
if sprite == self:
raise Exception("trying to add sprite to itself")
if sprite.parent:
sprite.x, sprit... | [
"def",
"_add",
"(",
"self",
",",
"sprite",
",",
"index",
"=",
"None",
")",
":",
"if",
"sprite",
"==",
"self",
":",
"raise",
"Exception",
"(",
"\"trying to add sprite to itself\"",
")",
"if",
"sprite",
".",
"parent",
":",
"sprite",
".",
"x",
",",
"sprite"... | add one sprite at a time. used by add_child. split them up so that
it would be possible specify the index externally | [
"add",
"one",
"sprite",
"at",
"a",
"time",
".",
"used",
"by",
"add_child",
".",
"split",
"them",
"up",
"so",
"that",
"it",
"would",
"be",
"possible",
"specify",
"the",
"index",
"externally"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L711-L725 |
232,054 | projecthamster/hamster | src/hamster/lib/graphics.py | Parent._sort | def _sort(self):
"""sort sprites by z_order"""
self.__dict__['_z_ordered_sprites'] = sorted(self.sprites, key=lambda sprite:sprite.z_order) | python | def _sort(self):
"""sort sprites by z_order"""
self.__dict__['_z_ordered_sprites'] = sorted(self.sprites, key=lambda sprite:sprite.z_order) | [
"def",
"_sort",
"(",
"self",
")",
":",
"self",
".",
"__dict__",
"[",
"'_z_ordered_sprites'",
"]",
"=",
"sorted",
"(",
"self",
".",
"sprites",
",",
"key",
"=",
"lambda",
"sprite",
":",
"sprite",
".",
"z_order",
")"
] | sort sprites by z_order | [
"sort",
"sprites",
"by",
"z_order"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L728-L730 |
232,055 | projecthamster/hamster | src/hamster/lib/graphics.py | Parent.add_child | def add_child(self, *sprites):
"""Add child sprite. Child will be nested within parent"""
for sprite in sprites:
self._add(sprite)
self._sort()
self.redraw() | python | def add_child(self, *sprites):
"""Add child sprite. Child will be nested within parent"""
for sprite in sprites:
self._add(sprite)
self._sort()
self.redraw() | [
"def",
"add_child",
"(",
"self",
",",
"*",
"sprites",
")",
":",
"for",
"sprite",
"in",
"sprites",
":",
"self",
".",
"_add",
"(",
"sprite",
")",
"self",
".",
"_sort",
"(",
")",
"self",
".",
"redraw",
"(",
")"
] | Add child sprite. Child will be nested within parent | [
"Add",
"child",
"sprite",
".",
"Child",
"will",
"be",
"nested",
"within",
"parent"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L732-L737 |
232,056 | projecthamster/hamster | src/hamster/lib/graphics.py | Parent.all_child_sprites | def all_child_sprites(self):
"""returns all child and grandchild sprites in a flat list"""
for sprite in self.sprites:
for child_sprite in sprite.all_child_sprites():
yield child_sprite
yield sprite | python | def all_child_sprites(self):
"""returns all child and grandchild sprites in a flat list"""
for sprite in self.sprites:
for child_sprite in sprite.all_child_sprites():
yield child_sprite
yield sprite | [
"def",
"all_child_sprites",
"(",
"self",
")",
":",
"for",
"sprite",
"in",
"self",
".",
"sprites",
":",
"for",
"child_sprite",
"in",
"sprite",
".",
"all_child_sprites",
"(",
")",
":",
"yield",
"child_sprite",
"yield",
"sprite"
] | returns all child and grandchild sprites in a flat list | [
"returns",
"all",
"child",
"and",
"grandchild",
"sprites",
"in",
"a",
"flat",
"list"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L774-L779 |
232,057 | projecthamster/hamster | src/hamster/lib/graphics.py | Parent.disconnect_child | def disconnect_child(self, sprite, *handlers):
"""disconnects from child event. if handler is not specified, will
disconnect from all the child sprite events"""
handlers = handlers or self._child_handlers.get(sprite, [])
for handler in list(handlers):
if sprite.handler_is_con... | python | def disconnect_child(self, sprite, *handlers):
"""disconnects from child event. if handler is not specified, will
disconnect from all the child sprite events"""
handlers = handlers or self._child_handlers.get(sprite, [])
for handler in list(handlers):
if sprite.handler_is_con... | [
"def",
"disconnect_child",
"(",
"self",
",",
"sprite",
",",
"*",
"handlers",
")",
":",
"handlers",
"=",
"handlers",
"or",
"self",
".",
"_child_handlers",
".",
"get",
"(",
"sprite",
",",
"[",
"]",
")",
"for",
"handler",
"in",
"list",
"(",
"handlers",
")... | disconnects from child event. if handler is not specified, will
disconnect from all the child sprite events | [
"disconnects",
"from",
"child",
"event",
".",
"if",
"handler",
"is",
"not",
"specified",
"will",
"disconnect",
"from",
"all",
"the",
"child",
"sprite",
"events"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L807-L818 |
232,058 | projecthamster/hamster | src/hamster/lib/graphics.py | Sprite._get_mouse_cursor | def _get_mouse_cursor(self):
"""Determine mouse cursor.
By default look for self.mouse_cursor is defined and take that.
Otherwise use gdk.CursorType.FLEUR for draggable sprites and gdk.CursorType.HAND2 for
interactive sprites. Defaults to scenes cursor.
"""
if self.mouse_... | python | def _get_mouse_cursor(self):
"""Determine mouse cursor.
By default look for self.mouse_cursor is defined and take that.
Otherwise use gdk.CursorType.FLEUR for draggable sprites and gdk.CursorType.HAND2 for
interactive sprites. Defaults to scenes cursor.
"""
if self.mouse_... | [
"def",
"_get_mouse_cursor",
"(",
"self",
")",
":",
"if",
"self",
".",
"mouse_cursor",
"is",
"not",
"None",
":",
"return",
"self",
".",
"mouse_cursor",
"elif",
"self",
".",
"interactive",
"and",
"self",
".",
"draggable",
":",
"return",
"gdk",
".",
"CursorTy... | Determine mouse cursor.
By default look for self.mouse_cursor is defined and take that.
Otherwise use gdk.CursorType.FLEUR for draggable sprites and gdk.CursorType.HAND2 for
interactive sprites. Defaults to scenes cursor. | [
"Determine",
"mouse",
"cursor",
".",
"By",
"default",
"look",
"for",
"self",
".",
"mouse_cursor",
"is",
"defined",
"and",
"take",
"that",
".",
"Otherwise",
"use",
"gdk",
".",
"CursorType",
".",
"FLEUR",
"for",
"draggable",
"sprites",
"and",
"gdk",
".",
"Cu... | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L1026-L1037 |
232,059 | projecthamster/hamster | src/hamster/lib/graphics.py | Sprite.bring_to_front | def bring_to_front(self):
"""adjusts sprite's z-order so that the sprite is on top of it's
siblings"""
if not self.parent:
return
self.z_order = self.parent._z_ordered_sprites[-1].z_order + 1 | python | def bring_to_front(self):
"""adjusts sprite's z-order so that the sprite is on top of it's
siblings"""
if not self.parent:
return
self.z_order = self.parent._z_ordered_sprites[-1].z_order + 1 | [
"def",
"bring_to_front",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"parent",
":",
"return",
"self",
".",
"z_order",
"=",
"self",
".",
"parent",
".",
"_z_ordered_sprites",
"[",
"-",
"1",
"]",
".",
"z_order",
"+",
"1"
] | adjusts sprite's z-order so that the sprite is on top of it's
siblings | [
"adjusts",
"sprite",
"s",
"z",
"-",
"order",
"so",
"that",
"the",
"sprite",
"is",
"on",
"top",
"of",
"it",
"s",
"siblings"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L1039-L1044 |
232,060 | projecthamster/hamster | src/hamster/lib/graphics.py | Sprite.send_to_back | def send_to_back(self):
"""adjusts sprite's z-order so that the sprite is behind it's
siblings"""
if not self.parent:
return
self.z_order = self.parent._z_ordered_sprites[0].z_order - 1 | python | def send_to_back(self):
"""adjusts sprite's z-order so that the sprite is behind it's
siblings"""
if not self.parent:
return
self.z_order = self.parent._z_ordered_sprites[0].z_order - 1 | [
"def",
"send_to_back",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"parent",
":",
"return",
"self",
".",
"z_order",
"=",
"self",
".",
"parent",
".",
"_z_ordered_sprites",
"[",
"0",
"]",
".",
"z_order",
"-",
"1"
] | adjusts sprite's z-order so that the sprite is behind it's
siblings | [
"adjusts",
"sprite",
"s",
"z",
"-",
"order",
"so",
"that",
"the",
"sprite",
"is",
"behind",
"it",
"s",
"siblings"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L1046-L1051 |
232,061 | projecthamster/hamster | src/hamster/lib/graphics.py | Sprite.blur | def blur(self):
"""removes focus from the current element if it has it"""
scene = self.get_scene()
if scene and scene._focus_sprite == self:
scene._focus_sprite = None | python | def blur(self):
"""removes focus from the current element if it has it"""
scene = self.get_scene()
if scene and scene._focus_sprite == self:
scene._focus_sprite = None | [
"def",
"blur",
"(",
"self",
")",
":",
"scene",
"=",
"self",
".",
"get_scene",
"(",
")",
"if",
"scene",
"and",
"scene",
".",
"_focus_sprite",
"==",
"self",
":",
"scene",
".",
"_focus_sprite",
"=",
"None"
] | removes focus from the current element if it has it | [
"removes",
"focus",
"from",
"the",
"current",
"element",
"if",
"it",
"has",
"it"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L1067-L1071 |
232,062 | projecthamster/hamster | src/hamster/lib/graphics.py | Sprite.get_parents | def get_parents(self):
"""returns all the parent sprites up until scene"""
res = []
parent = self.parent
while parent and isinstance(parent, Scene) == False:
res.insert(0, parent)
parent = parent.parent
return res | python | def get_parents(self):
"""returns all the parent sprites up until scene"""
res = []
parent = self.parent
while parent and isinstance(parent, Scene) == False:
res.insert(0, parent)
parent = parent.parent
return res | [
"def",
"get_parents",
"(",
"self",
")",
":",
"res",
"=",
"[",
"]",
"parent",
"=",
"self",
".",
"parent",
"while",
"parent",
"and",
"isinstance",
"(",
"parent",
",",
"Scene",
")",
"==",
"False",
":",
"res",
".",
"insert",
"(",
"0",
",",
"parent",
")... | returns all the parent sprites up until scene | [
"returns",
"all",
"the",
"parent",
"sprites",
"up",
"until",
"scene"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L1077-L1085 |
232,063 | projecthamster/hamster | src/hamster/lib/graphics.py | Sprite.get_extents | def get_extents(self):
"""measure the extents of the sprite's graphics."""
if self._sprite_dirty:
# redrawing merely because we need fresh extents of the sprite
context = cairo.Context(cairo.ImageSurface(cairo.FORMAT_A1, 0, 0))
context.transform(self.get_matrix())
... | python | def get_extents(self):
"""measure the extents of the sprite's graphics."""
if self._sprite_dirty:
# redrawing merely because we need fresh extents of the sprite
context = cairo.Context(cairo.ImageSurface(cairo.FORMAT_A1, 0, 0))
context.transform(self.get_matrix())
... | [
"def",
"get_extents",
"(",
"self",
")",
":",
"if",
"self",
".",
"_sprite_dirty",
":",
"# redrawing merely because we need fresh extents of the sprite",
"context",
"=",
"cairo",
".",
"Context",
"(",
"cairo",
".",
"ImageSurface",
"(",
"cairo",
".",
"FORMAT_A1",
",",
... | measure the extents of the sprite's graphics. | [
"measure",
"the",
"extents",
"of",
"the",
"sprite",
"s",
"graphics",
"."
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L1088-L1152 |
232,064 | projecthamster/hamster | src/hamster/lib/graphics.py | Sprite.check_hit | def check_hit(self, x, y):
"""check if the given coordinates are inside the sprite's fill or stroke path"""
extents = self.get_extents()
if not extents:
return False
if extents.x <= x <= extents.x + extents.width and extents.y <= y <= extents.y + extents.height:
... | python | def check_hit(self, x, y):
"""check if the given coordinates are inside the sprite's fill or stroke path"""
extents = self.get_extents()
if not extents:
return False
if extents.x <= x <= extents.x + extents.width and extents.y <= y <= extents.y + extents.height:
... | [
"def",
"check_hit",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"extents",
"=",
"self",
".",
"get_extents",
"(",
")",
"if",
"not",
"extents",
":",
"return",
"False",
"if",
"extents",
".",
"x",
"<=",
"x",
"<=",
"extents",
".",
"x",
"+",
"extents",
... | check if the given coordinates are inside the sprite's fill or stroke path | [
"check",
"if",
"the",
"given",
"coordinates",
"are",
"inside",
"the",
"sprite",
"s",
"fill",
"or",
"stroke",
"path"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L1155-L1165 |
232,065 | projecthamster/hamster | src/hamster/lib/graphics.py | Sprite.get_matrix | def get_matrix(self):
"""return sprite's current transformation matrix"""
if self.parent:
return self.get_local_matrix() * (self._prev_parent_matrix or self.parent.get_matrix())
else:
return self.get_local_matrix() | python | def get_matrix(self):
"""return sprite's current transformation matrix"""
if self.parent:
return self.get_local_matrix() * (self._prev_parent_matrix or self.parent.get_matrix())
else:
return self.get_local_matrix() | [
"def",
"get_matrix",
"(",
"self",
")",
":",
"if",
"self",
".",
"parent",
":",
"return",
"self",
".",
"get_local_matrix",
"(",
")",
"*",
"(",
"self",
".",
"_prev_parent_matrix",
"or",
"self",
".",
"parent",
".",
"get_matrix",
"(",
")",
")",
"else",
":",... | return sprite's current transformation matrix | [
"return",
"sprite",
"s",
"current",
"transformation",
"matrix"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L1238-L1243 |
232,066 | projecthamster/hamster | src/hamster/lib/graphics.py | Sprite.from_scene_coords | def from_scene_coords(self, x=0, y=0):
"""Converts x, y given in the scene coordinates to sprite's local ones
coordinates"""
matrix = self.get_matrix()
matrix.invert()
return matrix.transform_point(x, y) | python | def from_scene_coords(self, x=0, y=0):
"""Converts x, y given in the scene coordinates to sprite's local ones
coordinates"""
matrix = self.get_matrix()
matrix.invert()
return matrix.transform_point(x, y) | [
"def",
"from_scene_coords",
"(",
"self",
",",
"x",
"=",
"0",
",",
"y",
"=",
"0",
")",
":",
"matrix",
"=",
"self",
".",
"get_matrix",
"(",
")",
"matrix",
".",
"invert",
"(",
")",
"return",
"matrix",
".",
"transform_point",
"(",
"x",
",",
"y",
")"
] | Converts x, y given in the scene coordinates to sprite's local ones
coordinates | [
"Converts",
"x",
"y",
"given",
"in",
"the",
"scene",
"coordinates",
"to",
"sprite",
"s",
"local",
"ones",
"coordinates"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L1246-L1251 |
232,067 | projecthamster/hamster | src/hamster/lib/graphics.py | Scene.stop_animation | def stop_animation(self, sprites):
"""stop animation without firing on_complete"""
if isinstance(sprites, list) is False:
sprites = [sprites]
for sprite in sprites:
self.tweener.kill_tweens(sprite) | python | def stop_animation(self, sprites):
"""stop animation without firing on_complete"""
if isinstance(sprites, list) is False:
sprites = [sprites]
for sprite in sprites:
self.tweener.kill_tweens(sprite) | [
"def",
"stop_animation",
"(",
"self",
",",
"sprites",
")",
":",
"if",
"isinstance",
"(",
"sprites",
",",
"list",
")",
"is",
"False",
":",
"sprites",
"=",
"[",
"sprites",
"]",
"for",
"sprite",
"in",
"sprites",
":",
"self",
".",
"tweener",
".",
"kill_twe... | stop animation without firing on_complete | [
"stop",
"animation",
"without",
"firing",
"on_complete"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L1950-L1956 |
232,068 | projecthamster/hamster | src/hamster/lib/graphics.py | Scene.redraw | def redraw(self):
"""Queue redraw. The redraw will be performed not more often than
the `framerate` allows"""
if self.__drawing_queued == False: #if we are moving, then there is a timeout somewhere already
self.__drawing_queued = True
self._last_frame_time = dt.datetim... | python | def redraw(self):
"""Queue redraw. The redraw will be performed not more often than
the `framerate` allows"""
if self.__drawing_queued == False: #if we are moving, then there is a timeout somewhere already
self.__drawing_queued = True
self._last_frame_time = dt.datetim... | [
"def",
"redraw",
"(",
"self",
")",
":",
"if",
"self",
".",
"__drawing_queued",
"==",
"False",
":",
"#if we are moving, then there is a timeout somewhere already",
"self",
".",
"__drawing_queued",
"=",
"True",
"self",
".",
"_last_frame_time",
"=",
"dt",
".",
"datetim... | Queue redraw. The redraw will be performed not more often than
the `framerate` allows | [
"Queue",
"redraw",
".",
"The",
"redraw",
"will",
"be",
"performed",
"not",
"more",
"often",
"than",
"the",
"framerate",
"allows"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L1959-L1965 |
232,069 | projecthamster/hamster | src/hamster/lib/graphics.py | Scene.__redraw_loop | def __redraw_loop(self):
"""loop until there is nothing more to tween"""
self.queue_draw() # this will trigger do_expose_event when the current events have been flushed
self.__drawing_queued = self.tweener and self.tweener.has_tweens()
return self.__drawing_queued | python | def __redraw_loop(self):
"""loop until there is nothing more to tween"""
self.queue_draw() # this will trigger do_expose_event when the current events have been flushed
self.__drawing_queued = self.tweener and self.tweener.has_tweens()
return self.__drawing_queued | [
"def",
"__redraw_loop",
"(",
"self",
")",
":",
"self",
".",
"queue_draw",
"(",
")",
"# this will trigger do_expose_event when the current events have been flushed",
"self",
".",
"__drawing_queued",
"=",
"self",
".",
"tweener",
"and",
"self",
".",
"tweener",
".",
"has_... | loop until there is nothing more to tween | [
"loop",
"until",
"there",
"is",
"nothing",
"more",
"to",
"tween"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L1967-L1972 |
232,070 | projecthamster/hamster | src/hamster/lib/graphics.py | Scene.all_mouse_sprites | def all_mouse_sprites(self):
"""Returns flat list of the sprite tree for simplified iteration"""
def all_recursive(sprites):
if not sprites:
return
for sprite in sprites:
if sprite.visible:
yield sprite
for... | python | def all_mouse_sprites(self):
"""Returns flat list of the sprite tree for simplified iteration"""
def all_recursive(sprites):
if not sprites:
return
for sprite in sprites:
if sprite.visible:
yield sprite
for... | [
"def",
"all_mouse_sprites",
"(",
"self",
")",
":",
"def",
"all_recursive",
"(",
"sprites",
")",
":",
"if",
"not",
"sprites",
":",
"return",
"for",
"sprite",
"in",
"sprites",
":",
"if",
"sprite",
".",
"visible",
":",
"yield",
"sprite",
"for",
"child",
"in... | Returns flat list of the sprite tree for simplified iteration | [
"Returns",
"flat",
"list",
"of",
"the",
"sprite",
"tree",
"for",
"simplified",
"iteration"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L2024-L2037 |
232,071 | projecthamster/hamster | src/hamster/lib/graphics.py | Scene.get_sprite_at_position | def get_sprite_at_position(self, x, y):
"""Returns the topmost visible interactive sprite for given coordinates"""
over = None
for sprite in self.all_mouse_sprites():
if sprite.interactive and sprite.check_hit(x, y):
over = sprite
return over | python | def get_sprite_at_position(self, x, y):
"""Returns the topmost visible interactive sprite for given coordinates"""
over = None
for sprite in self.all_mouse_sprites():
if sprite.interactive and sprite.check_hit(x, y):
over = sprite
return over | [
"def",
"get_sprite_at_position",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"over",
"=",
"None",
"for",
"sprite",
"in",
"self",
".",
"all_mouse_sprites",
"(",
")",
":",
"if",
"sprite",
".",
"interactive",
"and",
"sprite",
".",
"check_hit",
"(",
"x",
",... | Returns the topmost visible interactive sprite for given coordinates | [
"Returns",
"the",
"topmost",
"visible",
"interactive",
"sprite",
"for",
"given",
"coordinates"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L2040-L2047 |
232,072 | projecthamster/hamster | src/hamster/lib/graphics.py | Scene.start_drag | def start_drag(self, sprite, cursor_x = None, cursor_y = None):
"""start dragging given sprite"""
cursor_x, cursor_y = cursor_x or sprite.x, cursor_y or sprite.y
self._mouse_down_sprite = self._drag_sprite = sprite
sprite.drag_x, sprite.drag_y = self._drag_sprite.x, self._drag_sprite.y
... | python | def start_drag(self, sprite, cursor_x = None, cursor_y = None):
"""start dragging given sprite"""
cursor_x, cursor_y = cursor_x or sprite.x, cursor_y or sprite.y
self._mouse_down_sprite = self._drag_sprite = sprite
sprite.drag_x, sprite.drag_y = self._drag_sprite.x, self._drag_sprite.y
... | [
"def",
"start_drag",
"(",
"self",
",",
"sprite",
",",
"cursor_x",
"=",
"None",
",",
"cursor_y",
"=",
"None",
")",
":",
"cursor_x",
",",
"cursor_y",
"=",
"cursor_x",
"or",
"sprite",
".",
"x",
",",
"cursor_y",
"or",
"sprite",
".",
"y",
"self",
".",
"_m... | start dragging given sprite | [
"start",
"dragging",
"given",
"sprite"
] | ca5254eff53172796ddafc72226c394ed1858245 | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L2158-L2165 |
232,073 | readbeyond/aeneas | aeneas/logger.py | Logger.pretty_print | def pretty_print(self, as_list=False, show_datetime=True):
"""
Return a Unicode string pretty print of the log entries.
:param bool as_list: if ``True``, return a list of Unicode strings,
one for each entry, instead of a Unicode string
:param bool show_datet... | python | def pretty_print(self, as_list=False, show_datetime=True):
"""
Return a Unicode string pretty print of the log entries.
:param bool as_list: if ``True``, return a list of Unicode strings,
one for each entry, instead of a Unicode string
:param bool show_datet... | [
"def",
"pretty_print",
"(",
"self",
",",
"as_list",
"=",
"False",
",",
"show_datetime",
"=",
"True",
")",
":",
"ppl",
"=",
"[",
"entry",
".",
"pretty_print",
"(",
"show_datetime",
")",
"for",
"entry",
"in",
"self",
".",
"entries",
"]",
"if",
"as_list",
... | Return a Unicode string pretty print of the log entries.
:param bool as_list: if ``True``, return a list of Unicode strings,
one for each entry, instead of a Unicode string
:param bool show_datetime: if ``True``, show the date and time of the entries
:rtype: string ... | [
"Return",
"a",
"Unicode",
"string",
"pretty",
"print",
"of",
"the",
"log",
"entries",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/logger.py#L130-L142 |
232,074 | readbeyond/aeneas | aeneas/logger.py | Logger.log | def log(self, message, severity=INFO, tag=u""):
"""
Add a given message to the log, and return its time.
:param string message: the message to be added
:param severity: the severity of the message
:type severity: :class:`~aeneas.logger.Logger`
:param string tag: the tag... | python | def log(self, message, severity=INFO, tag=u""):
"""
Add a given message to the log, and return its time.
:param string message: the message to be added
:param severity: the severity of the message
:type severity: :class:`~aeneas.logger.Logger`
:param string tag: the tag... | [
"def",
"log",
"(",
"self",
",",
"message",
",",
"severity",
"=",
"INFO",
",",
"tag",
"=",
"u\"\"",
")",
":",
"entry",
"=",
"_LogEntry",
"(",
"severity",
"=",
"severity",
",",
"time",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
",",
"tag... | Add a given message to the log, and return its time.
:param string message: the message to be added
:param severity: the severity of the message
:type severity: :class:`~aeneas.logger.Logger`
:param string tag: the tag associated with the message;
usually, th... | [
"Add",
"a",
"given",
"message",
"to",
"the",
"log",
"and",
"return",
"its",
"time",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/logger.py#L144-L165 |
232,075 | readbeyond/aeneas | aeneas/logger.py | Logger.write | def write(self, path):
"""
Output the log to file.
:param string path: the path of the log file to be written
"""
with io.open(path, "w", encoding="utf-8") as log_file:
log_file.write(self.pretty_print()) | python | def write(self, path):
"""
Output the log to file.
:param string path: the path of the log file to be written
"""
with io.open(path, "w", encoding="utf-8") as log_file:
log_file.write(self.pretty_print()) | [
"def",
"write",
"(",
"self",
",",
"path",
")",
":",
"with",
"io",
".",
"open",
"(",
"path",
",",
"\"w\"",
",",
"encoding",
"=",
"\"utf-8\"",
")",
"as",
"log_file",
":",
"log_file",
".",
"write",
"(",
"self",
".",
"pretty_print",
"(",
")",
")"
] | Output the log to file.
:param string path: the path of the log file to be written | [
"Output",
"the",
"log",
"to",
"file",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/logger.py#L173-L180 |
232,076 | readbeyond/aeneas | aeneas/logger.py | _LogEntry.pretty_print | def pretty_print(self, show_datetime=True):
"""
Returns a Unicode string containing
the pretty printing of a given log entry.
:param bool show_datetime: if ``True``, print the date and time of the entry
:rtype: string
"""
if show_datetime:
return u"[%... | python | def pretty_print(self, show_datetime=True):
"""
Returns a Unicode string containing
the pretty printing of a given log entry.
:param bool show_datetime: if ``True``, print the date and time of the entry
:rtype: string
"""
if show_datetime:
return u"[%... | [
"def",
"pretty_print",
"(",
"self",
",",
"show_datetime",
"=",
"True",
")",
":",
"if",
"show_datetime",
":",
"return",
"u\"[%s] %s %s%s: %s\"",
"%",
"(",
"self",
".",
"severity",
",",
"gf",
".",
"object_to_unicode",
"(",
"self",
".",
"time",
")",
",",
"u\"... | Returns a Unicode string containing
the pretty printing of a given log entry.
:param bool show_datetime: if ``True``, print the date and time of the entry
:rtype: string | [
"Returns",
"a",
"Unicode",
"string",
"containing",
"the",
"pretty",
"printing",
"of",
"a",
"given",
"log",
"entry",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/logger.py#L219-L240 |
232,077 | readbeyond/aeneas | aeneas/logger.py | Loggable._log | def _log(self, message, severity=Logger.DEBUG):
"""
Log generic message
:param string message: the message to log
:param string severity: the message severity
:rtype: datetime
"""
return self.logger.log(message, severity, self.TAG) | python | def _log(self, message, severity=Logger.DEBUG):
"""
Log generic message
:param string message: the message to log
:param string severity: the message severity
:rtype: datetime
"""
return self.logger.log(message, severity, self.TAG) | [
"def",
"_log",
"(",
"self",
",",
"message",
",",
"severity",
"=",
"Logger",
".",
"DEBUG",
")",
":",
"return",
"self",
".",
"logger",
".",
"log",
"(",
"message",
",",
"severity",
",",
"self",
".",
"TAG",
")"
] | Log generic message
:param string message: the message to log
:param string severity: the message severity
:rtype: datetime | [
"Log",
"generic",
"message"
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/logger.py#L323-L331 |
232,078 | readbeyond/aeneas | aeneas/logger.py | Loggable.log_exc | def log_exc(self, message, exc=None, critical=True, raise_type=None):
"""
Log exception, and possibly raise exception.
:param string message: the message to log
:param Exception exc: the original exception
:param bool critical: if ``True``, log as :data:`aeneas.logger.Logger.CRI... | python | def log_exc(self, message, exc=None, critical=True, raise_type=None):
"""
Log exception, and possibly raise exception.
:param string message: the message to log
:param Exception exc: the original exception
:param bool critical: if ``True``, log as :data:`aeneas.logger.Logger.CRI... | [
"def",
"log_exc",
"(",
"self",
",",
"message",
",",
"exc",
"=",
"None",
",",
"critical",
"=",
"True",
",",
"raise_type",
"=",
"None",
")",
":",
"log_function",
"=",
"self",
".",
"log_crit",
"if",
"critical",
"else",
"self",
".",
"log_warn",
"log_function... | Log exception, and possibly raise exception.
:param string message: the message to log
:param Exception exc: the original exception
:param bool critical: if ``True``, log as :data:`aeneas.logger.Logger.CRITICAL`;
otherwise as :data:`aeneas.logger.Logger.WARNING`
... | [
"Log",
"exception",
"and",
"possibly",
"raise",
"exception",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/logger.py#L333-L351 |
232,079 | readbeyond/aeneas | aeneas/plotter.py | Plotter.add_waveform | def add_waveform(self, waveform):
"""
Add a waveform to the plot.
:param waveform: the waveform to be added
:type waveform: :class:`~aeneas.plotter.PlotWaveform`
:raises: TypeError: if ``waveform`` is not an instance of :class:`~aeneas.plotter.PlotWaveform`
"""
... | python | def add_waveform(self, waveform):
"""
Add a waveform to the plot.
:param waveform: the waveform to be added
:type waveform: :class:`~aeneas.plotter.PlotWaveform`
:raises: TypeError: if ``waveform`` is not an instance of :class:`~aeneas.plotter.PlotWaveform`
"""
... | [
"def",
"add_waveform",
"(",
"self",
",",
"waveform",
")",
":",
"if",
"not",
"isinstance",
"(",
"waveform",
",",
"PlotWaveform",
")",
":",
"self",
".",
"log_exc",
"(",
"u\"waveform must be an instance of PlotWaveform\"",
",",
"None",
",",
"True",
",",
"TypeError"... | Add a waveform to the plot.
:param waveform: the waveform to be added
:type waveform: :class:`~aeneas.plotter.PlotWaveform`
:raises: TypeError: if ``waveform`` is not an instance of :class:`~aeneas.plotter.PlotWaveform` | [
"Add",
"a",
"waveform",
"to",
"the",
"plot",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/plotter.py#L100-L111 |
232,080 | readbeyond/aeneas | aeneas/plotter.py | Plotter.add_timescale | def add_timescale(self, timescale):
"""
Add a time scale to the plot.
:param timescale: the timescale to be added
:type timescale: :class:`~aeneas.plotter.PlotTimeScale`
:raises: TypeError: if ``timescale`` is not an instance of :class:`~aeneas.plotter.PlotTimeScale`
""... | python | def add_timescale(self, timescale):
"""
Add a time scale to the plot.
:param timescale: the timescale to be added
:type timescale: :class:`~aeneas.plotter.PlotTimeScale`
:raises: TypeError: if ``timescale`` is not an instance of :class:`~aeneas.plotter.PlotTimeScale`
""... | [
"def",
"add_timescale",
"(",
"self",
",",
"timescale",
")",
":",
"if",
"not",
"isinstance",
"(",
"timescale",
",",
"PlotTimeScale",
")",
":",
"self",
".",
"log_exc",
"(",
"u\"timescale must be an instance of PlotTimeScale\"",
",",
"None",
",",
"True",
",",
"Type... | Add a time scale to the plot.
:param timescale: the timescale to be added
:type timescale: :class:`~aeneas.plotter.PlotTimeScale`
:raises: TypeError: if ``timescale`` is not an instance of :class:`~aeneas.plotter.PlotTimeScale` | [
"Add",
"a",
"time",
"scale",
"to",
"the",
"plot",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/plotter.py#L113-L124 |
232,081 | readbeyond/aeneas | aeneas/plotter.py | Plotter.add_labelset | def add_labelset(self, labelset):
"""
Add a set of labels to the plot.
:param labelset: the set of labels to be added
:type labelset: :class:`~aeneas.plotter.PlotLabelset`
:raises: TypeError: if ``labelset`` is not an instance of :class:`~aeneas.plotter.PlotLabelset`
""... | python | def add_labelset(self, labelset):
"""
Add a set of labels to the plot.
:param labelset: the set of labels to be added
:type labelset: :class:`~aeneas.plotter.PlotLabelset`
:raises: TypeError: if ``labelset`` is not an instance of :class:`~aeneas.plotter.PlotLabelset`
""... | [
"def",
"add_labelset",
"(",
"self",
",",
"labelset",
")",
":",
"if",
"not",
"isinstance",
"(",
"labelset",
",",
"PlotLabelset",
")",
":",
"self",
".",
"log_exc",
"(",
"u\"labelset must be an instance of PlotLabelset\"",
",",
"None",
",",
"True",
",",
"TypeError"... | Add a set of labels to the plot.
:param labelset: the set of labels to be added
:type labelset: :class:`~aeneas.plotter.PlotLabelset`
:raises: TypeError: if ``labelset`` is not an instance of :class:`~aeneas.plotter.PlotLabelset` | [
"Add",
"a",
"set",
"of",
"labels",
"to",
"the",
"plot",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/plotter.py#L126-L137 |
232,082 | readbeyond/aeneas | aeneas/plotter.py | Plotter.draw_png | def draw_png(self, output_file_path, h_zoom=5, v_zoom=30):
"""
Draw the current plot to a PNG file.
:param string output_path: the path of the output file to be written
:param int h_zoom: the horizontal zoom
:param int v_zoom: the vertical zoom
:raises: ImportError: if m... | python | def draw_png(self, output_file_path, h_zoom=5, v_zoom=30):
"""
Draw the current plot to a PNG file.
:param string output_path: the path of the output file to be written
:param int h_zoom: the horizontal zoom
:param int v_zoom: the vertical zoom
:raises: ImportError: if m... | [
"def",
"draw_png",
"(",
"self",
",",
"output_file_path",
",",
"h_zoom",
"=",
"5",
",",
"v_zoom",
"=",
"30",
")",
":",
"# check that output_file_path can be written",
"if",
"not",
"gf",
".",
"file_can_be_written",
"(",
"output_file_path",
")",
":",
"self",
".",
... | Draw the current plot to a PNG file.
:param string output_path: the path of the output file to be written
:param int h_zoom: the horizontal zoom
:param int v_zoom: the vertical zoom
:raises: ImportError: if module ``PIL`` cannot be imported
:raises: OSError: if ``output_file_pat... | [
"Draw",
"the",
"current",
"plot",
"to",
"a",
"PNG",
"file",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/plotter.py#L139-L191 |
232,083 | readbeyond/aeneas | aeneas/plotter.py | PlotElement.text_bounding_box | def text_bounding_box(self, size_pt, text):
"""
Return the bounding box of the given text
at the given font size.
:param int size_pt: the font size in points
:param string text: the text
:rtype: tuple (width, height)
"""
if size_pt == 12:
mul... | python | def text_bounding_box(self, size_pt, text):
"""
Return the bounding box of the given text
at the given font size.
:param int size_pt: the font size in points
:param string text: the text
:rtype: tuple (width, height)
"""
if size_pt == 12:
mul... | [
"def",
"text_bounding_box",
"(",
"self",
",",
"size_pt",
",",
"text",
")",
":",
"if",
"size_pt",
"==",
"12",
":",
"mult",
"=",
"{",
"\"h\"",
":",
"9",
",",
"\"w_digit\"",
":",
"5",
",",
"\"w_space\"",
":",
"2",
"}",
"elif",
"size_pt",
"==",
"18",
"... | Return the bounding box of the given text
at the given font size.
:param int size_pt: the font size in points
:param string text: the text
:rtype: tuple (width, height) | [
"Return",
"the",
"bounding",
"box",
"of",
"the",
"given",
"text",
"at",
"the",
"given",
"font",
"size",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/plotter.py#L237-L252 |
232,084 | readbeyond/aeneas | aeneas/plotter.py | PlotTimeScale.draw_png | def draw_png(self, image, h_zoom, v_zoom, current_y):
"""
Draw this time scale to PNG.
:param image: the image to draw onto
:param int h_zoom: the horizontal zoom
:param int v_zoom: the vertical zoom
:param int current_y: the current y offset, in modules
:type i... | python | def draw_png(self, image, h_zoom, v_zoom, current_y):
"""
Draw this time scale to PNG.
:param image: the image to draw onto
:param int h_zoom: the horizontal zoom
:param int v_zoom: the vertical zoom
:param int current_y: the current y offset, in modules
:type i... | [
"def",
"draw_png",
"(",
"self",
",",
"image",
",",
"h_zoom",
",",
"v_zoom",
",",
"current_y",
")",
":",
"# PIL object",
"draw",
"=",
"ImageDraw",
".",
"Draw",
"(",
"image",
")",
"mws",
"=",
"self",
".",
"rconf",
".",
"mws",
"pixels_per_second",
"=",
"i... | Draw this time scale to PNG.
:param image: the image to draw onto
:param int h_zoom: the horizontal zoom
:param int v_zoom: the vertical zoom
:param int current_y: the current y offset, in modules
:type image: :class:`PIL.Image` | [
"Draw",
"this",
"time",
"scale",
"to",
"PNG",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/plotter.py#L305-L341 |
232,085 | readbeyond/aeneas | aeneas/plotter.py | PlotWaveform.draw_png | def draw_png(self, image, h_zoom, v_zoom, current_y):
"""
Draw this waveform to PNG.
:param image: the image to draw onto
:param int h_zoom: the horizontal zoom
:param int v_zoom: the vertical zoom
:param int current_y: the current y offset, in modules
:type ima... | python | def draw_png(self, image, h_zoom, v_zoom, current_y):
"""
Draw this waveform to PNG.
:param image: the image to draw onto
:param int h_zoom: the horizontal zoom
:param int v_zoom: the vertical zoom
:param int current_y: the current y offset, in modules
:type ima... | [
"def",
"draw_png",
"(",
"self",
",",
"image",
",",
"h_zoom",
",",
"v_zoom",
",",
"current_y",
")",
":",
"draw",
"=",
"ImageDraw",
".",
"Draw",
"(",
"image",
")",
"mws",
"=",
"self",
".",
"rconf",
".",
"mws",
"rate",
"=",
"self",
".",
"audio_file",
... | Draw this waveform to PNG.
:param image: the image to draw onto
:param int h_zoom: the horizontal zoom
:param int v_zoom: the vertical zoom
:param int current_y: the current y offset, in modules
:type image: :class:`PIL.Image` | [
"Draw",
"this",
"waveform",
"to",
"PNG",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/plotter.py#L524-L567 |
232,086 | readbeyond/aeneas | aeneas/tools/run_sd.py | RunSDCLI.print_result | def print_result(self, audio_len, start, end):
"""
Print result of SD.
:param audio_len: the length of the entire audio file, in seconds
:type audio_len: float
:param start: the start position of the spoken text
:type start: float
:param end: the end position o... | python | def print_result(self, audio_len, start, end):
"""
Print result of SD.
:param audio_len: the length of the entire audio file, in seconds
:type audio_len: float
:param start: the start position of the spoken text
:type start: float
:param end: the end position o... | [
"def",
"print_result",
"(",
"self",
",",
"audio_len",
",",
"start",
",",
"end",
")",
":",
"msg",
"=",
"[",
"]",
"zero",
"=",
"0",
"head_len",
"=",
"start",
"text_len",
"=",
"end",
"-",
"start",
"tail_len",
"=",
"audio_len",
"-",
"end",
"msg",
".",
... | Print result of SD.
:param audio_len: the length of the entire audio file, in seconds
:type audio_len: float
:param start: the start position of the spoken text
:type start: float
:param end: the end position of the spoken text
:type end: float | [
"Print",
"result",
"of",
"SD",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/run_sd.py#L171-L203 |
232,087 | readbeyond/aeneas | aeneas/task.py | Task.sync_map_leaves | def sync_map_leaves(self, fragment_type=None):
"""
Return the list of non-empty leaves
in the sync map associated with the task.
If ``fragment_type`` has been specified,
return only leaves of that fragment type.
:param int fragment_type: type of fragment to return
... | python | def sync_map_leaves(self, fragment_type=None):
"""
Return the list of non-empty leaves
in the sync map associated with the task.
If ``fragment_type`` has been specified,
return only leaves of that fragment type.
:param int fragment_type: type of fragment to return
... | [
"def",
"sync_map_leaves",
"(",
"self",
",",
"fragment_type",
"=",
"None",
")",
":",
"if",
"(",
"self",
".",
"sync_map",
"is",
"None",
")",
"or",
"(",
"self",
".",
"sync_map",
".",
"fragments_tree",
"is",
"None",
")",
":",
"return",
"[",
"]",
"return",
... | Return the list of non-empty leaves
in the sync map associated with the task.
If ``fragment_type`` has been specified,
return only leaves of that fragment type.
:param int fragment_type: type of fragment to return
:rtype: list
.. versionadded:: 1.7.0 | [
"Return",
"the",
"list",
"of",
"non",
"-",
"empty",
"leaves",
"in",
"the",
"sync",
"map",
"associated",
"with",
"the",
"task",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/task.py#L149-L164 |
232,088 | readbeyond/aeneas | aeneas/task.py | Task.output_sync_map_file | def output_sync_map_file(self, container_root_path=None):
"""
Output the sync map file for this task.
If ``container_root_path`` is specified,
the output sync map file will be created
at the path obtained by joining
the ``container_root_path`` and the relative path
... | python | def output_sync_map_file(self, container_root_path=None):
"""
Output the sync map file for this task.
If ``container_root_path`` is specified,
the output sync map file will be created
at the path obtained by joining
the ``container_root_path`` and the relative path
... | [
"def",
"output_sync_map_file",
"(",
"self",
",",
"container_root_path",
"=",
"None",
")",
":",
"if",
"self",
".",
"sync_map",
"is",
"None",
":",
"self",
".",
"log_exc",
"(",
"u\"The sync_map object has not been set\"",
",",
"None",
",",
"True",
",",
"TypeError",... | Output the sync map file for this task.
If ``container_root_path`` is specified,
the output sync map file will be created
at the path obtained by joining
the ``container_root_path`` and the relative path
of the sync map inside the container.
Otherwise, the sync map file... | [
"Output",
"the",
"sync",
"map",
"file",
"for",
"this",
"task",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/task.py#L166-L227 |
232,089 | readbeyond/aeneas | aeneas/task.py | Task._populate_audio_file | def _populate_audio_file(self):
"""
Create the ``self.audio_file`` object by reading
the audio file at ``self.audio_file_path_absolute``.
"""
self.log(u"Populate audio file...")
if self.audio_file_path_absolute is not None:
self.log([u"audio_file_path_absolute... | python | def _populate_audio_file(self):
"""
Create the ``self.audio_file`` object by reading
the audio file at ``self.audio_file_path_absolute``.
"""
self.log(u"Populate audio file...")
if self.audio_file_path_absolute is not None:
self.log([u"audio_file_path_absolute... | [
"def",
"_populate_audio_file",
"(",
"self",
")",
":",
"self",
".",
"log",
"(",
"u\"Populate audio file...\"",
")",
"if",
"self",
".",
"audio_file_path_absolute",
"is",
"not",
"None",
":",
"self",
".",
"log",
"(",
"[",
"u\"audio_file_path_absolute is '%s'\"",
",",
... | Create the ``self.audio_file`` object by reading
the audio file at ``self.audio_file_path_absolute``. | [
"Create",
"the",
"self",
".",
"audio_file",
"object",
"by",
"reading",
"the",
"audio",
"file",
"at",
"self",
".",
"audio_file_path_absolute",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/task.py#L229-L244 |
232,090 | readbeyond/aeneas | aeneas/task.py | Task._populate_text_file | def _populate_text_file(self):
"""
Create the ``self.text_file`` object by reading
the text file at ``self.text_file_path_absolute``.
"""
self.log(u"Populate text file...")
if (
(self.text_file_path_absolute is not None) and
(self.configura... | python | def _populate_text_file(self):
"""
Create the ``self.text_file`` object by reading
the text file at ``self.text_file_path_absolute``.
"""
self.log(u"Populate text file...")
if (
(self.text_file_path_absolute is not None) and
(self.configura... | [
"def",
"_populate_text_file",
"(",
"self",
")",
":",
"self",
".",
"log",
"(",
"u\"Populate text file...\"",
")",
"if",
"(",
"(",
"self",
".",
"text_file_path_absolute",
"is",
"not",
"None",
")",
"and",
"(",
"self",
".",
"configuration",
"[",
"\"language\"",
... | Create the ``self.text_file`` object by reading
the text file at ``self.text_file_path_absolute``. | [
"Create",
"the",
"self",
".",
"text_file",
"object",
"by",
"reading",
"the",
"text",
"file",
"at",
"self",
".",
"text_file_path_absolute",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/task.py#L246-L278 |
232,091 | readbeyond/aeneas | aeneas/syncmap/smfgxml.py | SyncMapFormatGenericXML._tree_to_string | def _tree_to_string(cls, root_element, xml_declaration=True, pretty_print=True):
"""
Return an ``lxml`` tree as a Unicode string.
"""
from lxml import etree
return gf.safe_unicode(etree.tostring(
root_element,
encoding="UTF-8",
method="xml",
... | python | def _tree_to_string(cls, root_element, xml_declaration=True, pretty_print=True):
"""
Return an ``lxml`` tree as a Unicode string.
"""
from lxml import etree
return gf.safe_unicode(etree.tostring(
root_element,
encoding="UTF-8",
method="xml",
... | [
"def",
"_tree_to_string",
"(",
"cls",
",",
"root_element",
",",
"xml_declaration",
"=",
"True",
",",
"pretty_print",
"=",
"True",
")",
":",
"from",
"lxml",
"import",
"etree",
"return",
"gf",
".",
"safe_unicode",
"(",
"etree",
".",
"tostring",
"(",
"root_elem... | Return an ``lxml`` tree as a Unicode string. | [
"Return",
"an",
"lxml",
"tree",
"as",
"a",
"Unicode",
"string",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/smfgxml.py#L63-L74 |
232,092 | readbeyond/aeneas | aeneas/tools/abstract_cli_program.py | AbstractCLIProgram.print_generic | def print_generic(self, msg, prefix=None):
"""
Print a message and log it.
:param msg: the message
:type msg: Unicode string
:param prefix: the (optional) prefix
:type prefix: Unicode string
"""
if prefix is None:
self._log(msg, Logger.INFO)... | python | def print_generic(self, msg, prefix=None):
"""
Print a message and log it.
:param msg: the message
:type msg: Unicode string
:param prefix: the (optional) prefix
:type prefix: Unicode string
"""
if prefix is None:
self._log(msg, Logger.INFO)... | [
"def",
"print_generic",
"(",
"self",
",",
"msg",
",",
"prefix",
"=",
"None",
")",
":",
"if",
"prefix",
"is",
"None",
":",
"self",
".",
"_log",
"(",
"msg",
",",
"Logger",
".",
"INFO",
")",
"else",
":",
"self",
".",
"_log",
"(",
"msg",
",",
"prefix... | Print a message and log it.
:param msg: the message
:type msg: Unicode string
:param prefix: the (optional) prefix
:type prefix: Unicode string | [
"Print",
"a",
"message",
"and",
"log",
"it",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/abstract_cli_program.py#L109-L126 |
232,093 | readbeyond/aeneas | aeneas/tools/abstract_cli_program.py | AbstractCLIProgram.print_name_version | def print_name_version(self):
"""
Print program name and version and exit.
:rtype: int
"""
if self.use_sys:
self.print_generic(u"%s v%s" % (self.NAME, aeneas_version))
return self.exit(self.HELP_EXIT_CODE) | python | def print_name_version(self):
"""
Print program name and version and exit.
:rtype: int
"""
if self.use_sys:
self.print_generic(u"%s v%s" % (self.NAME, aeneas_version))
return self.exit(self.HELP_EXIT_CODE) | [
"def",
"print_name_version",
"(",
"self",
")",
":",
"if",
"self",
".",
"use_sys",
":",
"self",
".",
"print_generic",
"(",
"u\"%s v%s\"",
"%",
"(",
"self",
".",
"NAME",
",",
"aeneas_version",
")",
")",
"return",
"self",
".",
"exit",
"(",
"self",
".",
"H... | Print program name and version and exit.
:rtype: int | [
"Print",
"program",
"name",
"and",
"version",
"and",
"exit",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/abstract_cli_program.py#L260-L268 |
232,094 | readbeyond/aeneas | aeneas/tools/abstract_cli_program.py | AbstractCLIProgram.print_rconf_parameters | def print_rconf_parameters(self):
"""
Print the list of runtime configuration parameters and exit.
"""
if self.use_sys:
self.print_info(u"Available runtime configuration parameters:")
self.print_generic(u"\n" + u"\n".join(self.RCONF_PARAMETERS) + u"\n")
re... | python | def print_rconf_parameters(self):
"""
Print the list of runtime configuration parameters and exit.
"""
if self.use_sys:
self.print_info(u"Available runtime configuration parameters:")
self.print_generic(u"\n" + u"\n".join(self.RCONF_PARAMETERS) + u"\n")
re... | [
"def",
"print_rconf_parameters",
"(",
"self",
")",
":",
"if",
"self",
".",
"use_sys",
":",
"self",
".",
"print_info",
"(",
"u\"Available runtime configuration parameters:\"",
")",
"self",
".",
"print_generic",
"(",
"u\"\\n\"",
"+",
"u\"\\n\"",
".",
"join",
"(",
... | Print the list of runtime configuration parameters and exit. | [
"Print",
"the",
"list",
"of",
"runtime",
"configuration",
"parameters",
"and",
"exit",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/abstract_cli_program.py#L270-L277 |
232,095 | readbeyond/aeneas | aeneas/tools/abstract_cli_program.py | AbstractCLIProgram.has_option | def has_option(self, target):
"""
Return ``True`` if the actual arguments include
the specified ``target`` option or,
if ``target`` is a list of options,
at least one of them.
:param target: the option or a list of options
:type target: Unicode string or list of... | python | def has_option(self, target):
"""
Return ``True`` if the actual arguments include
the specified ``target`` option or,
if ``target`` is a list of options,
at least one of them.
:param target: the option or a list of options
:type target: Unicode string or list of... | [
"def",
"has_option",
"(",
"self",
",",
"target",
")",
":",
"if",
"isinstance",
"(",
"target",
",",
"list",
")",
":",
"target_set",
"=",
"set",
"(",
"target",
")",
"else",
":",
"target_set",
"=",
"set",
"(",
"[",
"target",
"]",
")",
"return",
"len",
... | Return ``True`` if the actual arguments include
the specified ``target`` option or,
if ``target`` is a list of options,
at least one of them.
:param target: the option or a list of options
:type target: Unicode string or list of Unicode strings
:rtype: bool | [
"Return",
"True",
"if",
"the",
"actual",
"arguments",
"include",
"the",
"specified",
"target",
"option",
"or",
"if",
"target",
"is",
"a",
"list",
"of",
"options",
"at",
"least",
"one",
"of",
"them",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/abstract_cli_program.py#L387-L402 |
232,096 | readbeyond/aeneas | aeneas/tools/abstract_cli_program.py | AbstractCLIProgram.check_c_extensions | def check_c_extensions(self, name=None):
"""
If C extensions cannot be run, emit a warning
and return ``False``. Otherwise return ``True``.
If ``name`` is not ``None``, check just
the C extension with that name.
:param name: the name of the Python C extension to test
... | python | def check_c_extensions(self, name=None):
"""
If C extensions cannot be run, emit a warning
and return ``False``. Otherwise return ``True``.
If ``name`` is not ``None``, check just
the C extension with that name.
:param name: the name of the Python C extension to test
... | [
"def",
"check_c_extensions",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"not",
"gf",
".",
"can_run_c_extension",
"(",
"name",
"=",
"name",
")",
":",
"if",
"name",
"is",
"None",
":",
"self",
".",
"print_warning",
"(",
"u\"Unable to load Python C... | If C extensions cannot be run, emit a warning
and return ``False``. Otherwise return ``True``.
If ``name`` is not ``None``, check just
the C extension with that name.
:param name: the name of the Python C extension to test
:type name: string
:rtype: bool | [
"If",
"C",
"extensions",
"cannot",
"be",
"run",
"emit",
"a",
"warning",
"and",
"return",
"False",
".",
"Otherwise",
"return",
"True",
".",
"If",
"name",
"is",
"not",
"None",
"check",
"just",
"the",
"C",
"extension",
"with",
"that",
"name",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/abstract_cli_program.py#L437-L456 |
232,097 | readbeyond/aeneas | aeneas/tools/abstract_cli_program.py | AbstractCLIProgram.check_output_file | def check_output_file(self, path):
"""
If the given path cannot be written, emit an error
and return ``False``. Otherwise return ``True``.
:param path: the path of the output file
:type path: string (path)
:rtype: bool
"""
if not gf.file_can_be_written(p... | python | def check_output_file(self, path):
"""
If the given path cannot be written, emit an error
and return ``False``. Otherwise return ``True``.
:param path: the path of the output file
:type path: string (path)
:rtype: bool
"""
if not gf.file_can_be_written(p... | [
"def",
"check_output_file",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"gf",
".",
"file_can_be_written",
"(",
"path",
")",
":",
"self",
".",
"print_error",
"(",
"u\"Unable to create file '%s'\"",
"%",
"(",
"path",
")",
")",
"self",
".",
"print_error",
... | If the given path cannot be written, emit an error
and return ``False``. Otherwise return ``True``.
:param path: the path of the output file
:type path: string (path)
:rtype: bool | [
"If",
"the",
"given",
"path",
"cannot",
"be",
"written",
"emit",
"an",
"error",
"and",
"return",
"False",
".",
"Otherwise",
"return",
"True",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/abstract_cli_program.py#L488-L501 |
232,098 | readbeyond/aeneas | aeneas/tools/abstract_cli_program.py | AbstractCLIProgram.check_output_directory | def check_output_directory(self, path):
"""
If the given directory cannot be written, emit an error
and return ``False``. Otherwise return ``True``.
:param path: the path of the output directory
:type path: string (path)
:rtype: bool
"""
if not os.path.i... | python | def check_output_directory(self, path):
"""
If the given directory cannot be written, emit an error
and return ``False``. Otherwise return ``True``.
:param path: the path of the output directory
:type path: string (path)
:rtype: bool
"""
if not os.path.i... | [
"def",
"check_output_directory",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"self",
".",
"print_error",
"(",
"u\"Directory '%s' does not exist\"",
"%",
"(",
"path",
")",
")",
"return",
"False",
... | If the given directory cannot be written, emit an error
and return ``False``. Otherwise return ``True``.
:param path: the path of the output directory
:type path: string (path)
:rtype: bool | [
"If",
"the",
"given",
"directory",
"cannot",
"be",
"written",
"emit",
"an",
"error",
"and",
"return",
"False",
".",
"Otherwise",
"return",
"True",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/abstract_cli_program.py#L503-L520 |
232,099 | readbeyond/aeneas | aeneas/container.py | Container.is_safe | def is_safe(self):
"""
Return ``True`` if the container can be safely extracted,
that is, if all its entries are safe, ``False`` otherwise.
:rtype: bool
:raises: same as :func:`~aeneas.container.Container.entries`
"""
self.log(u"Checking if this container is safe... | python | def is_safe(self):
"""
Return ``True`` if the container can be safely extracted,
that is, if all its entries are safe, ``False`` otherwise.
:rtype: bool
:raises: same as :func:`~aeneas.container.Container.entries`
"""
self.log(u"Checking if this container is safe... | [
"def",
"is_safe",
"(",
"self",
")",
":",
"self",
".",
"log",
"(",
"u\"Checking if this container is safe\"",
")",
"for",
"entry",
"in",
"self",
".",
"entries",
":",
"if",
"not",
"self",
".",
"is_entry_safe",
"(",
"entry",
")",
":",
"self",
".",
"log",
"(... | Return ``True`` if the container can be safely extracted,
that is, if all its entries are safe, ``False`` otherwise.
:rtype: bool
:raises: same as :func:`~aeneas.container.Container.entries` | [
"Return",
"True",
"if",
"the",
"container",
"can",
"be",
"safely",
"extracted",
"that",
"is",
"if",
"all",
"its",
"entries",
"are",
"safe",
"False",
"otherwise",
"."
] | 9d95535ad63eef4a98530cfdff033b8c35315ee1 | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/container.py#L186-L200 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.