text stringlengths 0 828 |
|---|
kwarg_name = conversion_table[column] |
# Set the kwarg to the correct value from the row. |
kwdict[kwarg_name] = row[counter] |
counter += 1 |
return kwdict" |
1684,"def parse_datetime(time_str): |
"""""" |
Wraps dateutil's parser function to set an explicit UTC timezone, and |
to make sure microseconds are 0. Unified Uploader format and EMK format |
bother don't use microseconds at all. |
:param str time_str: The date/time str to parse. |
:rtype: datetime.datetime |
:returns: A parsed, UTC datetime. |
"""""" |
try: |
return dateutil.parser.parse( |
time_str |
).replace(microsecond=0).astimezone(UTC_TZINFO) |
except ValueError: |
# This was some kind of unrecognizable time string. |
raise ParseError(""Invalid time string: %s"" % time_str)" |
1685,"def merge(self, po_file, source_files): |
""""""从源码中获取所有条目,合并到 po_file 中。 |
:param string po_file: 待写入的 po 文件路径。 |
:param list source_files : 所有待处理的原文件路径 list。 |
"""""" |
# Create a temporary file to write pot file |
pot_file = tempfile.NamedTemporaryFile(mode='wb', prefix='rookout_', delete=False) |
pot_filename = pot_file.name |
slog.info('Create POT file [%s].', pot_filename) |
xargs = [self._xgettext, |
""--package-name=main"", |
""--package-version=0.1"", |
""--default-domain=main"", |
""--from-code=UTF-8"", |
""-C"", ""-k_"", |
""--output"", pot_filename] |
txt = subprocess.check_output(xargs+source_files, |
stderr=subprocess.STDOUT, |
universal_newlines=True) |
if len(txt) > 0: |
raise(ChildProcessError(txt)) |
slog.info('Start merge [%s] to [%s].', pot_filename, po_file) |
xargs = [self._msgmerge, ""-U"", po_file, pot_filename] |
txt = subprocess.check_output(xargs, universal_newlines=True) |
slog.info(txt) |
pot_file.close() |
os.remove(pot_filename)" |
1686,"def fmt(self, po_file, mo_file): |
""""""将 po 文件转换成 mo 文件。 |
:param string po_file: 待转换的 po 文件路径。 |
:param string mo_file: 目标 mo 文件的路径。 |
"""""" |
if not os.path.exists(po_file): |
slog.error('The PO file [%s] is non-existen!'%po_file) |
return |
txt = subprocess.check_output([self._msgfmt, |
'--check', ""--strict"", '--verbose', |
""--output-file"", mo_file, po_file], |
stderr=subprocess.STDOUT, |
universal_newlines=True) |
slog.info(txt)" |
1687,"def add_suffix(filename, suffix): |
"""""" |
ADD suffix TO THE filename (NOT INCLUDING THE FILE EXTENSION) |
"""""" |
path = filename.split(""/"") |
parts = path[-1].split(""."") |
i = max(len(parts) - 2, 0) |
parts[i] = parts[i] + suffix |
path[-1] = ""."".join(parts) |
return ""/"".join(path)" |
1688,"def find(self, pattern): |
"""""" |
:param pattern: REGULAR EXPRESSION TO MATCH NAME (NOT INCLUDING PATH) |
:return: LIST OF File OBJECTS THAT HAVE MATCHING NAME |
"""""" |
output = [] |
def _find(dir): |
if re.match(pattern, dir._filename.split(""/"")[-1]): |
output.append(dir) |
if dir.is_directory(): |
for c in dir.children: |
_find(c) |
_find(self) |
return output" |
1689,"def set_extension(self, ext): |
"""""" |
RETURN NEW FILE WITH GIVEN EXTENSION |
"""""" |
path = self._filename.split(""/"") |
parts = path[-1].split(""."") |
if len(parts) == 1: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.