rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
if not field.data or field.data != csrf_token: | is_valid = field.data and field.data == csrf_token field.data = self.reset_csrf() if not is_valid: | def validate_csrf(self, field): if not self.csrf_enabled or request.is_xhr: return csrf_token = session.pop('_csrf_token', None) if not field.data or field.data != csrf_token: raise ValidationError, "Missing or invalid CSRF token" |
self._request = kwargs.pop('request', request) self._session = kwargs.pop('session', session) | def __init__(self, formdata=None, *args, **kwargs): | |
self.csrf_enabled = kwargs.pop('csrf_enabled', True) | csrf_enabled = kwargs.pop('csrf_enabled', None) | def __init__(self, formdata=None, *args, **kwargs): |
self.csrf_enabled = self.csrf_enabled and \ current_app.config.get('CSRF_ENABLED', True) | if csrf_enabled is None: csrf_enabled = current_app.config.get('CSRF_ENABLED', True) self.csrf_enabled = csrf_enabled | def __init__(self, formdata=None, *args, **kwargs): |
res = check_page('/', ['Work', 'Material']) | res = check_page('/', ['Work', 'About']) | def check_page(path, required_contents, status=200): print "* Checking page '%s%s'" % (self.wui_address, path) res = self.app.get(path, status=status) for required in required_contents: print ' ...checking for %r' % required assert required in res, res return res |
assert 'Associated Material' in res | assert 'Editions' in res | def check_page(path, required_contents, status=200): print "* Checking page '%s%s'" % (self.wui_address, path) res = self.app.get(path, status=status) for required in required_contents: print ' ...checking for %r' % required assert required in res, res return res |
assert mattitle + '</a>' in res, res.showbrowser() | assert mattitle in res, res.showbrowser() | def check_page(path, required_contents, status=200): print "* Checking page '%s%s'" % (self.wui_address, path) res = self.app.get(path, status=status) for required in required_contents: print ' ...checking for %r' % required assert required in res, res return res |
model.Session.flush() | model.Session.commit() | def norm_work_name(out): if out.endswith('_f'): out = out[:-2] out = out.replace('_gut', '') out = out.replace('anthonie', 'antony') out = out.replace('errours', 'errors') out = out.replace('all_is', "alls") out = out.replace('loves_labour_', 'loves_labours_') out = out.replace('dreame', 'dream') out = out.replace('twe... |
res = model.Resource( | model.Resource( | def norm_work_name(out): out = out.replace('_moby', '') out = out.replace('life_and_death_of_king_john', 'john') out = out.replace('labor', 'labour') out = out.replace('part_iii', 'part_3') out = out.replace('part_ii', 'part_2') out = out.replace('part_i', 'part_1') return out |
locator='moby/pdf/%s.pdf' % item.name, | locator=u'moby/pdf/%s.pdf' % item.name, | def norm_work_name(out): out = out.replace('_moby', '') out = out.replace('life_and_death_of_king_john', 'john') out = out.replace('labor', 'labour') out = out.replace('part_iii', 'part_3') out = out.replace('part_ii', 'part_2') out = out.replace('part_i', 'part_1') return out |
model.Session.flush() | model.Session.commit() | def norm_work_name(out): out = out.replace('_moby', '') out = out.replace('life_and_death_of_king_john', 'john') out = out.replace('labor', 'labour') out = out.replace('part_iii', 'part_3') out = out.replace('part_ii', 'part_2') out = out.replace('part_i', 'part_1') return out |
'''Download Moby texts. | '''Download Moby xml texts. moby-download {path-to-download-to} If path not specified download to %(cachedir)s/moby/xml | def eb11(self): item = model.Material.by_name('shakespeare_eb11') if item is None: item = model.Material( name='shakespeare_eb11', title='William Shakespeare Entry in Encyclopaedia Brittanica 11th Edition (1911)', creator='Encylopaedia Britannica', src_pkg = pkg, src_locator = '/ancillary/britannica-11th.txt', format='... |
self.download() @classmethod | savepath = self.args[0] if self.args else None self.download(savepath) | def command(self): self._load_config() # TODO: allow specifying a path? self.download() |
savepath = os.path.abspath('shksprdata/moby') | conf = shakespeare.get_config() cachedir = os.path.abspath(conf['cachedir']) savepath = os.path.join(cachedir, 'moby') | def download(self, savepath=None): if not savepath: savepath = os.path.abspath('shksprdata/moby') if not os.path.exists(savepath): os.makedirs(savepath) import shksprdata.getdata.moby as moby h = moby.Helper(moby.index, savepath, verbose=self.verbose) h.all() |
support.reject_comment(comment_id, moderator=g.user.moderator) | support.reject_comment(comment_id, moderator=moderator) | def reject_comment(): moderator = g.user.moderator if g.user else False comment_id = request.form.get('id') support.reject_comment(comment_id, moderator=g.user.moderator) return 'OK' |
moderator=g.user.moderator) | moderator=moderator) | def delete_comment(): moderator = g.user.moderator if g.user else False username = g.user.name if g.user else '' comment_id = request.form.get('id') try: support.delete_comment(comment_id, username=username, moderator=g.user.moderator) except UserNotAuthorizedError: abort(401) return 'OK' |
@app.route('/docs/<docname>') | @app.route('/docs/<path:docname>') | def build(): support.build() return 'Build Complete' |
return self.format.length | return self.format.adjusted_length | def max_length(self): return self.format.length |
func = process.LerpFunc((1.0, 2.0, 3.0, 4.0), (-1.0, -2.0, -3.0, -4.0), 4) | func = process.LerpFunc((1.0, 2.0, 3.0, 4.0), (-1.0, -2.0, -3.0, -4.0), 5) | def test_quad(self): func = process.LerpFunc((1.0, 2.0, 3.0, 4.0), (-1.0, -2.0, -3.0, -4.0), 4) |
self.watchers[id(item)] = self.ItemWatcher(self, item, workspace_item) | self.watchers[id(item)] = watcher | def handle_item_added(self, item): if item.type() != 'video': return |
self.bottom_handle.setPos(0.0, self.height) | def __init__(self, item, name): QtGui.QGraphicsItem.__init__(self) Draggable.__init__(self, QtGui.QGraphicsItem) self.item = item | |
x=int(round(item.pos().x() * float(rate))), y=item.pos().y(), width=item.width, height=item.height)) | x=int(round(item.pos().x() * float(rate))), y=item.pos().y(), length=item.width, height=item.height)) | def dropEvent(self, event): # Turn them into real boys and girls items = [] |
self._thumbnail_painter.cancel_all_thumbnails() | self._thumbnail_painter.clear() | def _update(self, **kw): ''' Called by the item model to update our appearance. ''' # Changes requiring a reset of the thumbnails # TODO: This resets thumbnails *way* more than is necessary if 'width' in kw: self._thumbnail_painter.set_width(self.item.width) |
start, stop, step = key, key, 1 | start, stop, step = key, key + 1, 1 | def __setitem__(self, key, value): start, stop, step = None, None, None is_slice = isinstance(key, slice) items = None |
class VideoSequnce(VideoItem): | class VideoSequence(VideoItem): | def paint(self, painter, option, widget): rect = painter.transform().mapRect(self.boundingRect()) clip_rect = painter.transform().mapRect(option.exposedRect) |
class VerticalSnapMarker(QGraphicsItem): def __init__(self, frame, width): QGraphicsItem.__init__(self) self.frame = frame self.width = width self.setPos(frame, 0.0) def boundingRect(self): return QRectF(-width / 2.0, self.scene().scene_top, width / 2.0, self.scene().scene_bottom - self.scene().scene_top) def paint... | def paint(self, painter, option, widget): WIDTH = 3.0 rect = painter.transform().mapRect(self.boundingRect()) clip_rect = painter.transform().mapRect(option.exposedRect) | |
self._thumbnail_indexes = [0 + int(float(a) * frame_count / (count - 1)) for a in range(count)] | self._thumbnail_indexes = [0 + int(float(a) * (frame_count - 1) / (count - 1)) for a in range(count)] | def _create_thumbnails(self, total_width, height): # Calculate how many thumbnails fit box = self._stream.format.thumbnail_box aspect = self._stream.format.pixel_aspect_ratio frame_count = self._length |
for i, item in enumerate(self.list[stop:], stop): | for i, item in enumerate(self.list[start + len(items):], start + len(items)): | def _replace_range(self, start, stop, items): if self.index_attr: for i, item in enumerate(items, start): setattr(item, self.index_attr, i) |
self.assertEqual((fractions.Fraction(-1, 2), time), results[2]) | clock.seek(200) self.assertEqual((fractions.Fraction(-1, 2), 200), results[3]) | def callback(speed, time, data): data.append((speed, time)) |
self.assertEqual(len(results), 3) | self.assertEqual(len(results), 4) | def callback(speed, time, data): data.append((speed, time)) |
if 'x' in kw or 'width' in kw or 'offset' in kw: old_x, old_width, old_offset = self.workspace_item.x, self.workspace_item.width, self.workspace_item.offset new_x, new_width, new_offset = kw.get('x', old_x), kw.get('width', old_width), kw.get('offset', old_offset) | if 'x' in kw or 'length' in kw or 'offset' in kw: old_x, old_length, old_offset = self.workspace_item.x, self.workspace_item.length, self.workspace_item.offset new_x, new_length, new_offset = kw.get('x', old_x), kw.get('length', old_length), kw.get('offset', old_offset) | def handle_updated(self, **kw): # Raise the frames_updated signal if the content of frames changed if 'x' in kw or 'width' in kw or 'offset' in kw: old_x, old_width, old_offset = self.workspace_item.x, self.workspace_item.width, self.workspace_item.offset new_x, new_width, new_offset = kw.get('x', old_x), kw.get('width... |
width=kw.get('width', old_width), | length=kw.get('length', old_length), | def handle_updated(self, **kw): # Raise the frames_updated signal if the content of frames changed if 'x' in kw or 'width' in kw or 'offset' in kw: old_x, old_width, old_offset = self.workspace_item.x, self.workspace_item.width, self.workspace_item.offset new_x, new_width, new_offset = kw.get('x', old_x), kw.get('width... |
workspace_item = self.workspace.add(x=item.x, width=item.width, offset=item.offset, source=source) | workspace_item = self.workspace.add(x=item.x, length=item.length, offset=item.offset, source=source) | def handle_item_added(self, item): if not isinstance(item, model.Clip): return |
self.thumbnail_indexes = [start_frame + int(float(a) * frame_count / (count - 1)) for a in range(count)] | if count == 1: self.thumbnail_indexes = [start_frame] else: self.thumbnail_indexes = [start_frame + int(float(a) * frame_count / (count - 1)) for a in range(count)] | def _create_thumbnails(self, total_width): # Calculate how many thumbnails fit box = self.item.source.thumbnail_box aspect = self.item.source.pixel_aspect_ratio start_frame = self.item.offset frame_count = self.item.width |
painter.drawImage(rect.x() + (i * (rect.width() - self.thumbnail_width) / (len(self.thumbnails) - 1)), rect.y(), self.thumbnails[i]) | if len(self.thumbnails) == 1: painter.drawImage(rect.x() + (i * (rect.width() - self.thumbnail_width)), rect.y(), self.thumbnails[i]) else: painter.drawImage(rect.x() + (i * (rect.width() - self.thumbnail_width) / (len(self.thumbnails) - 1)), rect.y(), self.thumbnails[i]) | def paint(self, painter, option, widget): rect = painter.transform().mapRect(self.boundingRect()) clip_rect = painter.transform().mapRect(option.exposedRect) |
source = self.source_list.get_stream(item.source_name, item.source_stream_index) | source = None if isinstance(item.source, canvas.StreamSourceRef): source = self.source_list.get_stream(item.source.source_name, item.source.stream_index) | def handle_item_added(self, item): if not isinstance(item, canvas.Clip): return |
result = {'source_name': self._source_name, 'stream_index': self._stream_index} | result = {'source_name': data._source_name, 'stream_index': data._stream_index} | def to_yaml(cls, dumper, data): result = {'source_name': self._source_name, 'stream_index': self._stream_index} |
mapping = {'source': self._source, 'offset': self._offset, 'length': self._length} if self._transition_length: mapping['transition_length'] = self._transition_length if self._transition: mapping['transition'] = self._transition | mapping = {'source': data._source, 'offset': data._offset, 'length': data._length} if data._transition_length: mapping['transition_length'] = data._transition_length if data._transition: mapping['transition'] = data._transition | def to_yaml(cls, dumper, data): mapping = {'source': self._source, 'offset': self._offset, 'length': self._length} |
self.workspace_manager = VideoWorkspaceManager(self.space, self.source_list) self.workspace_manager.frames_updated.connect(self.handle_update_frames) | self.audio_workspace_manager = AudioWorkspaceManager(self.space, self.source_list) self.audio_player = process.AlsaPlayer(48000, 2, self.audio_workspace_manager.workspace) self.video_workspace_manager = VideoWorkspaceManager(self.space, self.source_list) self.video_workspace_manager.frames_updated.connect(self.handle_... | def __init__(self): QMainWindow.__init__(self) |
self.clock = process.SystemPresentationClock() | self.clock = self.audio_player | def __init__(self): QMainWindow.__init__(self) |
self.video_widget.setVideoSource(self.workspace_manager.workspace) | self.video_widget.setVideoSource(self.video_workspace_manager.workspace) | def __init__(self): QMainWindow.__init__(self) |
Use this to re-sort a single item after its key has changed. This method does the re-sort in-place, so it's faster than removing the item and adding it again. ''' item = self.list[index] key = item if self.keyfunc: key = self.keyfunc(item) if self.keys[index] == key: return new_index = bisect.bisect_left(self.keys, ... | self.add(item) | def move(self, index): ''' Check the key on the item at index and move it to its correct sort position. |
frame = scale.get_frame_f16( self.thumbnail_indexes[i], self.item.source.thumbnail_box) size = frame.current_data_window.size() img_str = frame.to_argb32_string() self.thumbnails[i] = QImage(img_str, size.x, size.y, QImage.Format_ARGB32_Premultiplied).copy() | self.thumbnails[i] = _PLACEHOLDER _queue.enqueue(source=scale, frame_index=self.thumbnail_indexes[i], window=self.item.source.thumbnail_box, callback=callback, user_data=(self.thumbnails, i)) | def paint(self, painter, option, widget): rect = painter.transform().mapRect(self.boundingRect()) clip_rect = painter.transform().mapRect(option.exposedRect) |
if len(self.thumbnails) == 1: painter.drawImage(rect.x() + (i * (rect.width() - self.thumbnail_width)), rect.y(), self.thumbnails[i]) else: painter.drawImage(rect.x() + (i * (rect.width() - self.thumbnail_width) / (len(self.thumbnails) - 1)), rect.y(), self.thumbnails[i]) | if self.thumbnails[i] is not _PLACEHOLDER: if len(self.thumbnails) == 1: painter.drawImage(rect.x() + (i * (rect.width() - self.thumbnail_width)), rect.y(), self.thumbnails[i]) else: painter.drawImage(rect.x() + (i * (rect.width() - self.thumbnail_width) / (len(self.thumbnails) - 1)), rect.y(), self.thumbnails[i]) | def paint(self, painter, option, widget): rect = painter.transform().mapRect(self.boundingRect()) clip_rect = painter.transform().mapRect(option.exposedRect) |
painter.setPen(QtGui.QPen(GtGui.QColor.fromRgbF(1.0, 1.0, 1.0), WIDTH)) | painter.setPen(QtGui.QPen(QtGui.QColor.fromRgbF(1.0, 1.0, 1.0), WIDTH)) | def paint(self, painter, option, widget): WIDTH = 3.0 rect = painter.transform().mapRect(self.boundingRect()) clip_rect = painter.transform().mapRect(option.exposedRect) |
source = self.source_list.get_stream(item.source_name, item.source_stream_id) | source = self.source_list.get_stream(item.source_name, item.source_stream_index) | def handle_item_added(self, item): if item.type() != 'video': return |
Called by handles to update the item's properties all at once. | Called by the item model to update our appearance. | def _update(self, **kw): ''' Called by handles to update the item's properties all at once. ''' # Alter the apparent Z-order of the item self.scene().resort_item(self) |
time = get_frame_time(self.frame_rate, frame) | time = process.get_frame_time(self.frame_rate, frame) | def on_frameScale_value_changed(self, control): if self.updating: return |
if self.original_width + x > self.parentItem().source.length: self.parentItem().item.update(width=self.parentItem().source.length) | if self.original_width + x > self.parentItem().max_length: self.parentItem().item.update(width=self.parentItem().max_length) | def drag_move(self, abs_pos, rel_pos): x = int(rel_pos.x()) |
return container.muxer in supported_muxers | return container.muxer in cls.supported_muxers | def handles_container(cls, container): return container.muxer in supported_muxers |
self.list = AutoIndexList(iterable, index_attr) | self.list = list(iterable) | def __cmp__(self, other): return cmpfunc(self.item, other.item) |
def _mock_function(self, func_name, func): | def _mock_function(self, obj, func): | def _mock_function(self, func_name, func): """ Replaces a bounded function in `self.breaker` by another. """ bounded_func = MethodType(func, self.breaker, type(self.breaker)) setattr(self.breaker, func_name, bounded_func) |
bounded_func = MethodType(func, self.breaker, type(self.breaker)) setattr(self.breaker, func_name, bounded_func) | setattr(obj, func.__name__, MethodType(func, self.breaker)) | def _mock_function(self, func_name, func): """ Replaces a bounded function in `self.breaker` by another. """ bounded_func = MethodType(func, self.breaker, type(self.breaker)) setattr(self.breaker, func_name, bounded_func) |
def slow_inc(self): | def _inc_counter(self): | def slow_inc(self): c = self._fail_counter sleep(0.00005) self._fail_counter = c + 1 |
self._mock_function('_inc_counter', slow_inc) | self._mock_function(self.breaker, _inc_counter) | def slow_inc(self): c = self._fail_counter sleep(0.00005) self._fail_counter = c + 1 |
header_locale = "res_index:table(nofallback) {\n CLDRVersion { " header_locale += CLDR_VERSION + " }\n InstalledLocales {\n" header = "res_index:table(nofallback) {\nInstalledLocales {\n" footer = " }\n}" empty_value = " {\"\"}\n" locale_index = open(os.path.join(TMP_DAT_PATH, res_index), "w") locale_index.write(he... | locales = set() brkitrs = set() colls = set() rbnfs = set() | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" header_locale = "res_index:table(nofallback) {\n CLDRVersion { " header_locale += CLDR_VERSION + " }\n InstalledLocales {\n" header = "res_index:table(nofallback) {\nInstalledLocales {\n" footer = " }\n}" empty_value = " {\"\"}\n" # key-value pair for... |
start = line.find("brkitr/") if start >= 0: | if line.find("brkitr/") >= 0: | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" header_locale = "res_index:table(nofallback) {\n CLDRVersion { " header_locale += CLDR_VERSION + " }\n InstalledLocales {\n" header = "res_index:table(nofallback) {\nInstalledLocales {\n" footer = " }\n}" empty_value = " {\"\"}\n" # key-value pair for... |
brkitr_index.write(line[line.find("/")+1:end] + empty_value) | brkitrs.add(line[line.find("/")+1:end]) | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" header_locale = "res_index:table(nofallback) {\n CLDRVersion { " header_locale += CLDR_VERSION + " }\n InstalledLocales {\n" header = "res_index:table(nofallback) {\nInstalledLocales {\n" footer = " }\n}" empty_value = " {\"\"}\n" # key-value pair for... |
start = line.find("coll/") | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" header_locale = "res_index:table(nofallback) {\n CLDRVersion { " header_locale += CLDR_VERSION + " }\n InstalledLocales {\n" header = "res_index:table(nofallback) {\nInstalledLocales {\n" footer = " }\n}" empty_value = " {\"\"}\n" # key-value pair for... | |
coll_index.write(line[line.find("/")+1:end] + empty_value) | colls.add(line[line.find("/")+1:end]) | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" header_locale = "res_index:table(nofallback) {\n CLDRVersion { " header_locale += CLDR_VERSION + " }\n InstalledLocales {\n" header = "res_index:table(nofallback) {\nInstalledLocales {\n" footer = " }\n}" empty_value = " {\"\"}\n" # key-value pair for... |
start = line.find("rbnf/") | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" header_locale = "res_index:table(nofallback) {\n CLDRVersion { " header_locale += CLDR_VERSION + " }\n InstalledLocales {\n" header = "res_index:table(nofallback) {\nInstalledLocales {\n" footer = " }\n}" empty_value = " {\"\"}\n" # key-value pair for... | |
rbnf_index.write(line[line.find("/")+1:end] + empty_value) | rbnfs.add(line[line.find("/")+1:end]) | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" header_locale = "res_index:table(nofallback) {\n CLDRVersion { " header_locale += CLDR_VERSION + " }\n InstalledLocales {\n" header = "res_index:table(nofallback) {\nInstalledLocales {\n" footer = " }\n}" empty_value = " {\"\"}\n" # key-value pair for... |
if end <= 3: locale_index.write(line[:end] + empty_value) elif line.find("_") <= 3: if line.find("_") > 0: locale_index.write(line[:end] + empty_value) locale_index.write(footer) brkitr_index.write(footer) coll_index.write(footer) rbnf_index.write(footer) locale_index.close() brkitr_index.close() coll_index.close() rb... | if end <= 3 or (line.find("_") <= 3 and line.find("_") > 0): locales.add(line[:end]) ShowMissing(brkitrs, locales, "brkitr", dat_list_file_path) ShowMissing(colls, locales, "coll", dat_list_file_path) ShowMissing(rbnfs, locales, "rbnf", dat_list_file_path) WriteIndex(os.path.join(TMP_DAT_PATH, res_index), locales, CL... | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" header_locale = "res_index:table(nofallback) {\n CLDRVersion { " header_locale += CLDR_VERSION + " }\n InstalledLocales {\n" header = "res_index:table(nofallback) {\nInstalledLocales {\n" footer = " }\n}" empty_value = " {\"\"}\n" # key-value pair for... |
InvokeIcuTool("genrb", os.path.join(TMP_DAT_PATH, "rbnf"), [res_index]) | if len(rbnfs): InvokeIcuTool("genrb", os.path.join(TMP_DAT_PATH, "rbnf"), [res_index]) | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" header_locale = "res_index:table(nofallback) {\n CLDRVersion { " header_locale += CLDR_VERSION + " }\n InstalledLocales {\n" header = "res_index:table(nofallback) {\nInstalledLocales {\n" footer = " }\n}" empty_value = " {\"\"}\n" # key-value pair for... |
return | sys.exit(1) | def main(): global ANDROID_ROOT # Android project home directory global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. global TMP_DAT_PATH # temp directory to store all re... |
if len(language) == 2: | if language != "pool" and language != "supplementalData": | def GenResIndex(input_file): res_index = "res_index.txt" brkitrs = set() colls = set() currs = set() langs = set() locales = set() regions = set() zones = set() for line in open(input_file, "r"): if "root." in line or "res_index" in line or "_.res" in line: continue if "brkitr/" in line: AddResFile(brkitrs, line) eli... |
print "icu_dat_generator.py icu-version [-v|--verbose] [-h|--help]" | print " icu_dat_generator.py [-v|--verbose] [-h|--help] ICU-VERSION" | def PrintHelp(): print "Usage:" print "icu_dat_generator.py icu-version [-v|--verbose] [-h|--help]" print "Example:" print "$ANDROID_BUILD_TOP/external/icu4c/stubdata$ ./icu_dat_generator.py 4.4" |
print "$ANDROID_BUILD_TOP/external/icu4c/stubdata$ ./icu_dat_generator.py 4.4" | print " $ANDROID_BUILD_TOP/external/icu4c/stubdata$ ./icu_dat_generator.py 4.4" sys.exit(1) | def PrintHelp(): print "Usage:" print "icu_dat_generator.py icu-version [-v|--verbose] [-h|--help]" print "Example:" print "$ANDROID_BUILD_TOP/external/icu4c/stubdata$ ./icu_dat_generator.py 4.4" |
source_dat = os.path.join(ANDROID_ROOT, "external", "icu4c", "stubdata", ICUDATA + "-all.dat") dest_dat = os.path.join(ANDROID_ROOT, "external", "icu4c", "stubdata", ICUDATA_DAT) | source_dat = os.path.join(ICU4C_DIR, "stubdata", ICUDATA + "-all.dat") dest_dat = os.path.join(ICU4C_DIR, "stubdata", ICUDATA_DAT) | def ExtractAllResourceToTempDir(): # copy icudtxxl-all.dat to icudtxxl.dat source_dat = os.path.join(ANDROID_ROOT, "external", "icu4c", "stubdata", ICUDATA + "-all.dat") dest_dat = os.path.join(ANDROID_ROOT, "external", "icu4c", "stubdata", ICUDATA_DAT) shutil.copyfile(source_dat, dest_dat) InvokeIcuTool("icupkg", None... |
dat_list_file_path = os.path.join(icu_dat_path, ICUDATA + "-" + dat_name + ".txt") | dat_list_file_path = os.path.join(icu_dat_path, ICUDATA + "-" + dat_name + ".txt") print "------ Processing '%s'..." % (dat_list_file_path) | def MakeDat(icu_dat_path, dat_name): # Get the resource list. e.g. icudt42l-us.txt, icudt42l-default.txt. dat_list_file_path = os.path.join(icu_dat_path, ICUDATA + "-" + dat_name + ".txt") if not os.path.isfile(dat_list_file_path): print "%s not present for resource list." % dat_list_file_path return GenResIndex(dat_li... |
InvokeIcuTool("icupkg", None, ["-tl", "-s", TMP_DAT_PATH, "-a", dat_list_file_path, "new", ICUDATA_DAT]) | args = ["-tl", "-s", TMP_DAT_PATH, "-a", dat_list_file_path, "new", ICUDATA_DAT] InvokeIcuTool("icupkg", None, args) | def MakeDat(icu_dat_path, dat_name): # Get the resource list. e.g. icudt42l-us.txt, icudt42l-default.txt. dat_list_file_path = os.path.join(icu_dat_path, ICUDATA + "-" + dat_name + ".txt") if not os.path.isfile(dat_list_file_path): print "%s not present for resource list." % dat_list_file_path return GenResIndex(dat_li... |
def ShowMissing(whats, locales, data_dir_name, dat_file): if not len(whats): return dat_file = os.path.basename(dat_file) for missing in locales.difference(whats): p = os.path.join(ANDROID_ROOT, "external", "icu4c", "data", data_dir_name, missing + ".txt") if os.path.exists(p): print "warning: %s exists but isn't inclu... | def AddResFile(collection, path): end = path.find(".res") if end > 0: collection.add(path[path.find("/")+1:end]) else: print "warning: ignoring '%s'; not a .res file" % (path.rstrip()) return | def ShowMissing(whats, locales, data_dir_name, dat_file): if not len(whats): return dat_file = os.path.basename(dat_file) for missing in locales.difference(whats): p = os.path.join(ANDROID_ROOT, "external", "icu4c", "data", data_dir_name, missing + ".txt") if os.path.exists(p): print "warning: %s exists but isn't inclu... |
locales = set() | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" locales = set() brkitrs = set() colls = set() currs = set() langs = set() regions = set() zones = set() rbnfs = set() for line in open(dat_list_file_path, "r"): if line.find("root.") >= 0: continue if line.find("res_index") >= 0: continue if line.find("... | |
rbnfs = set() | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" locales = set() brkitrs = set() colls = set() currs = set() langs = set() regions = set() zones = set() rbnfs = set() for line in open(dat_list_file_path, "r"): if line.find("root.") >= 0: continue if line.find("res_index") >= 0: continue if line.find("... | |
if line.find("root.") >= 0: continue if line.find("res_index") >= 0: continue if line.find("_.res") >= 0: | if "root." in line or "res_index" in line or "_.res" in line: | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" locales = set() brkitrs = set() colls = set() currs = set() langs = set() regions = set() zones = set() rbnfs = set() for line in open(dat_list_file_path, "r"): if line.find("root.") >= 0: continue if line.find("res_index") >= 0: continue if line.find("... |
if line.find("brkitr/") >= 0: end = line.find(".res") if end > 0: brkitrs.add(line[line.find("/")+1:end]) elif line.find("coll/") >= 0: end = line.find(".res") if end > 0: colls.add(line[line.find("/")+1:end]) elif line.find("curr/") >= 0: end = line.find(".res") if end > 0: currs.add(line[line.find("/")+1:end]) elif l... | if "brkitr/" in line: AddResFile(brkitrs, line) elif "coll/" in line: AddResFile(colls, line) elif "curr/" in line: AddResFile(currs, line) elif "lang/" in line: AddResFile(langs, line) elif "region/" in line: AddResFile(regions, line) elif "zone/" in line: AddResFile(zones, line) elif ".res" in line: | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" locales = set() brkitrs = set() colls = set() currs = set() langs = set() regions = set() zones = set() rbnfs = set() for line in open(dat_list_file_path, "r"): if line.find("root.") >= 0: continue if line.find("res_index") >= 0: continue if line.find("... |
ShowMissing(brkitrs, locales, "brkitr", dat_list_file_path) ShowMissing(colls, locales, "coll", dat_list_file_path) ShowMissing(currs, locales, "curr", dat_list_file_path) ShowMissing(langs, locales, "lang", dat_list_file_path) ShowMissing(regions, locales, "region", dat_list_file_path) ShowMissing(zones, locales, "zon... | kind_to_locales = { "brkitr": brkitrs, "coll": colls, "curr": currs, "lang": langs, "locales": locales, "region": regions, "zone": zones } every_locale = set() for locales in kind_to_locales.itervalues(): every_locale = every_locale.union(locales) if VERBOSE: for kind, locales in kind_to_locales.items(): print "%s=%... | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" locales = set() brkitrs = set() colls = set() currs = set() langs = set() regions = set() zones = set() rbnfs = set() for line in open(dat_list_file_path, "r"): if line.find("root.") >= 0: continue if line.find("res_index") >= 0: continue if line.find("... |
WriteIndex(os.path.join(TMP_DAT_PATH, "brkitr", res_index), brkitrs) WriteIndex(os.path.join(TMP_DAT_PATH, "coll", res_index), colls) WriteIndex(os.path.join(TMP_DAT_PATH, "curr", res_index), currs) WriteIndex(os.path.join(TMP_DAT_PATH, "lang", res_index), langs) WriteIndex(os.path.join(TMP_DAT_PATH, "region", res_inde... | for kind, locales in kind_to_locales.items(): if kind == "locales": continue WriteIndex(os.path.join(TMP_DAT_PATH, kind, res_index), locales) | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" locales = set() brkitrs = set() colls = set() currs = set() langs = set() regions = set() zones = set() rbnfs = set() for line in open(dat_list_file_path, "r"): if line.find("root.") >= 0: continue if line.find("res_index") >= 0: continue if line.find("... |
InvokeIcuTool("genrb", os.path.join(TMP_DAT_PATH, "brkitr"), [res_index]) InvokeIcuTool("genrb", os.path.join(TMP_DAT_PATH, "coll"), [res_index]) InvokeIcuTool("genrb", os.path.join(TMP_DAT_PATH, "curr"), [res_index]) InvokeIcuTool("genrb", os.path.join(TMP_DAT_PATH, "lang"), [res_index]) InvokeIcuTool("genrb", os.path... | for kind, locales in kind_to_locales.items(): if kind == "locales": continue InvokeIcuTool("genrb", os.path.join(TMP_DAT_PATH, kind), [res_index]) | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" locales = set() brkitrs = set() colls = set() currs = set() langs = set() regions = set() zones = set() rbnfs = set() for line in open(dat_list_file_path, "r"): if line.find("root.") >= 0: continue if line.find("res_index") >= 0: continue if line.find("... |
global ANDROID_ROOT | global ANDROID_BUILD_TOP global ICU4C_DIR | def main(): global ANDROID_ROOT # Android project home directory global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. global TMP_DAT_PATH # temp directory to store all re... |
global HELP | def main(): global ANDROID_ROOT # Android project home directory global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. global TMP_DAT_PATH # temp directory to store all re... | |
argc = len(sys.argv) if argc < 2: print "You must provide icu version number." print "Example: ./icu_dat_generator.py 4.4" | VERBOSE = False show_help = False try: opts, args = getopt.getopt(sys.argv[1:], 'hv', ['help', 'verbose']) except getopt.error: PrintHelpAndExit() for opt, arg in opts: if opt in ('-h', '--help'): show_help = True elif opt in ('-v', '--verbose'): VERBOSE = True if len(args) < 1: show_help = True if show_help: PrintHe... | def main(): global ANDROID_ROOT # Android project home directory global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. global TMP_DAT_PATH # temp directory to store all re... |
ICU_VERSION = sys.argv[1] version = GetIcuVersion(ICU_VERSION) if (version == -1): print sys.argv[1] + " is not a valid icu version number!" sys.exit(1) ICUDATA = "icudt" + version + "l" | ICUDATA = "icudt" + re.sub(r'([^0-9])', "", ICU_VERSION) + "l" | def main(): global ANDROID_ROOT # Android project home directory global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. global TMP_DAT_PATH # temp directory to store all re... |
ANDROID_ROOT = os.environ.get("ANDROID_BUILD_TOP") if not ANDROID_ROOT: | ANDROID_BUILD_TOP = os.environ.get("ANDROID_BUILD_TOP") if not ANDROID_BUILD_TOP: | def main(): global ANDROID_ROOT # Android project home directory global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. global TMP_DAT_PATH # temp directory to store all re... |
HELP = False VERBOSE = False try: opts, args = getopt.getopt(sys.argv[2:], 'hv', ['help', 'verbose']) except getopt.error: print "Invalid option" PrintHelp() sys.exit(1) for opt, arg in opts: if opt in ('-h', '--help'): PrintHelp() sys.exit(1) elif opt in ('-v', '--verbose'): VERBOSE = True icu_dat_path = os.path.j... | stubdata_dir = os.path.join(ICU4C_DIR, "stubdata") full_data_filename = os.path.join(stubdata_dir, ICUDATA + "-all.dat") | def main(): global ANDROID_ROOT # Android project home directory global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. global TMP_DAT_PATH # temp directory to store all re... |
TMP_DAT_PATH = os.path.join(ANDROID_ROOT, "external", "icu4c", "tmp") | TMP_DAT_PATH = os.path.join(ICU4C_DIR, "tmp") | def main(): global ANDROID_ROOT # Android project home directory global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. global TMP_DAT_PATH # temp directory to store all re... |
MakeDat(icu_dat_path, dat_subtag) | output_filename = os.path.join(stubdata_dir, ICUDATA + "-" + dat_subtag + ".dat") MakeDat(stubdata_dir, dat_subtag) | def main(): global ANDROID_ROOT # Android project home directory global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. global TMP_DAT_PATH # temp directory to store all re... |
shutil.copyfile(os.path.join(TMP_DAT_PATH, ICUDATA_DAT), os.path.join(icu_dat_path, ICUDATA + "-" + dat_subtag + ".dat")) print "Generate ICU data:" + os.path.join(icu_dat_path, ICUDATA + "-" + dat_subtag + ".dat") | shutil.copyfile(os.path.join(TMP_DAT_PATH, ICUDATA_DAT), output_filename) print "Generated ICU data: %s" % (output_filename) | def main(): global ANDROID_ROOT # Android project home directory global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. global TMP_DAT_PATH # temp directory to store all re... |
os.remove(os.path.join(icu_dat_path, ICUDATA_DAT)) | os.remove(os.path.join(stubdata_dir, ICUDATA_DAT)) | def main(): global ANDROID_ROOT # Android project home directory global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. global TMP_DAT_PATH # temp directory to store all re... |
else: print "warning: ignoring non-.res file %s" % path.rstrip() | def AddResFile(collection, path): end = path.find(".res") if end > 0: collection.add(path[path.find("/")+1:end]) else: # TODO(enh): this is a bug, right? we really just wanted to strip the # extension, and don't care whether it was .res or not? print "warning: ignoring non-.res file %s" % path.rstrip() return | |
print " icu_dat_generator.py [-v|--verbose] [-h|--help] ICU-VERSION" | print " icu_dat_generator.py [-v|--verbose] [-h|--help]" | def PrintHelpAndExit(): print "Usage:" print " icu_dat_generator.py [-v|--verbose] [-h|--help] ICU-VERSION" print "Example:" print " $ANDROID_BUILD_TOP/external/icu4c/stubdata$ ./icu_dat_generator.py 4.4" sys.exit(1) |
print " $ANDROID_BUILD_TOP/external/icu4c/stubdata$ ./icu_dat_generator.py 4.4" | print " $ANDROID_BUILD_TOP/external/icu4c/stubdata$ ./icu_dat_generator.py" | def PrintHelpAndExit(): print "Usage:" print " icu_dat_generator.py [-v|--verbose] [-h|--help] ICU-VERSION" print "Example:" print " $ANDROID_BUILD_TOP/external/icu4c/stubdata$ ./icu_dat_generator.py 4.4" sys.exit(1) |
command_list = [os.path.join(GetIcuPrebuiltDir(), tool)] | command_list = [os.path.join(ICU_PREBUILT_DIR, tool)] | def InvokeIcuTool(tool, working_dir, args): command_list = [os.path.join(GetIcuPrebuiltDir(), tool)] command_list.extend(args) if VERBOSE: command = "[%s] %s" % (working_dir, " ".join(command_list)) print command ret = subprocess.call(command_list, cwd = working_dir) if ret != 0: sys.exit(command_list[0:]) |
def GetIcuPrebuiltDir(): return os.path.join(os.environ.get("ANDROID_EABI_TOOLCHAIN"), "..", "..", "..", "icu-" + ICU_VERSION) | def GetIcuPrebuiltDir(): return os.path.join(os.environ.get("ANDROID_EABI_TOOLCHAIN"), "..", "..", "..", "icu-" + ICU_VERSION) | |
source_dat = os.path.join(ICU4C_DIR, "stubdata", ICUDATA + "-all.dat") dest_dat = os.path.join(ICU4C_DIR, "stubdata", ICUDATA_DAT) shutil.copyfile(source_dat, dest_dat) InvokeIcuTool("icupkg", None, [dest_dat, "-x", "*", "-d", TMP_DAT_PATH]) def MakeDat(icu_dat_path, dat_name): dat_list_file_path = os.path.join(icu_... | src_dat = os.path.join(ICU4C_DIR, "stubdata", ICUDATA + "-all.dat") dst_dat = os.path.join(ICU4C_DIR, "stubdata", ICUDATA + ".dat") shutil.copyfile(src_dat, dst_dat) InvokeIcuTool("icupkg", None, [dst_dat, "-x", "*", "-d", TMP_DAT_PATH]) def MakeDat(input_file, stubdata_dir): print "------ Processing '%s'..." % (inpu... | def ExtractAllResourceToTempDir(): # copy icudtxxl-all.dat to icudtxxl.dat source_dat = os.path.join(ICU4C_DIR, "stubdata", ICUDATA + "-all.dat") dest_dat = os.path.join(ICU4C_DIR, "stubdata", ICUDATA_DAT) shutil.copyfile(source_dat, dest_dat) InvokeIcuTool("icupkg", None, [dest_dat, "-x", "*", "-d", TMP_DAT_PATH]) |
for item in list: f.write(item + empty_value) | for locale in locales: f.write(locale + empty_value) | def WriteIndex(path, list, cldr_version = None): res_index = "res_index.txt" empty_value = " {\"\"}\n" # key-value pair for all locale entries f = open(path, "w") f.write("res_index:table(nofallback) {\n") if cldr_version: f.write(" CLDRVersion { %s }\n" % cldr_version) f.write(" InstalledLocales {\n") for item in ... |
print "warning: ignoring '%s'; not a .res file" % (path.rstrip()) | print "warning: ignoring non-.res file %s" % path.rstrip() | def AddResFile(collection, path): end = path.find(".res") if end > 0: collection.add(path[path.find("/")+1:end]) else: # TODO: this is a bug, right? we really just wanted to strip the extension, # and don't care whether it was .res or not? print "warning: ignoring '%s'; not a .res file" % (path.rstrip()) return |
def GenResIndex(dat_list_file_path): | def GenResIndex(input_file): | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" brkitrs = set() colls = set() currs = set() langs = set() locales = set() regions = set() zones = set() for line in open(dat_list_file_path, "r"): if "root." in line or "res_index" in line or "_.res" in line: continue; if "brkitr/" in line: AddResFile(b... |
for line in open(dat_list_file_path, "r"): | for line in open(input_file, "r"): | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" brkitrs = set() colls = set() currs = set() langs = set() locales = set() regions = set() zones = set() for line in open(dat_list_file_path, "r"): if "root." in line or "res_index" in line or "_.res" in line: continue; if "brkitr/" in line: AddResFile(b... |
continue; | continue | def GenResIndex(dat_list_file_path): res_index = "res_index.txt" brkitrs = set() colls = set() currs = set() langs = set() locales = set() regions = set() zones = set() for line in open(dat_list_file_path, "r"): if "root." in line or "res_index" in line or "_.res" in line: continue; if "brkitr/" in line: AddResFile(b... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.