rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
else: regExpParser = re.compile('Protection.*: d') if ( regExpParser.match(fileclassDirCheckOutput) == None): raise StageOutError("Output path is not a directory !") | def createOutputDirectory(self, targetPFN): """ _createOutputDirectory_ |
|
self.createDir(targetDir, self.permissions) else: regExpParser = re.compile('Protection.*: d') if ( regExpParser.match(targetDirCheckOutput) == None): raise StageOutError("Output path is not a directory !") | self.createDir(targetDir) | def createOutputDirectory(self, targetPFN): """ _createOutputDirectory_ |
def createDir(self, directory, mode): | def checkDirExists(self, directory): """ _checkDirExists_ Check if directory exists (will fail if it exists as a file) """ command = "rfstat %s 2> /dev/null | grep Protection" % directory print "Check dir existence : %s" % command try: exitCode, output = runCommandWithOutput(command) except Exception, ex: msg = "Error: Exception while invoking command:\n" msg += "%s\n" % command msg += "Exception: %s\n" % str(ex) msg += "Fatal error, abort stageout..." raise StageOutError(msg) if exitCode != 0: return False else: regExpParser = re.compile('^Protection[ ]+: d') if ( regExpParser.match(output) == None): raise StageOutError("Output path is not a directory !") else: return True def createDir(self, directory): | def createDir(self, directory, mode): """ _createDir_ |
Creates directory with no permissions """ cmd = "nsmkdir -m %s -p \"%s\"" % (mode, directory) execute(cmd) | Creates directory with correct permissions """ command = "(umask %s ; nsmkdir -m %s -p \"%s\")" % (self.umask, self.permissions, directory) execute(command) | def createDir(self, directory, mode): """ _createDir_ |
args['producer'] = 'ProdSys' args['step'] = 'Pass-1' | def httpPost(self, analysisFile): """ _httpPost_ |
|
args['workflow'] = self.inputDataset args['mssname'] = self.mssNames[filename] | def httpPost(self, analysisFile): """ _httpPost_ |
|
edit_toolbar_button, accelerator='<Ctrl>c') | edit_toolbar, accelerator='<Ctrl>c') | def _setup_toolbars(self, have_toolbox): """ Setup the toolbars.. """ project_toolbar = gtk.Toolbar() custom_slide_toolbar = gtk.Toolbar() custom_stator_toolbar = gtk.Toolbar() edit_toolbar = gtk.Toolbar() |
edit_toolbar_button, accelerator='<Ctrl>v') | edit_toolbar, accelerator='<Ctrl>v') | def _setup_toolbars(self, have_toolbox): """ Setup the toolbars.. """ project_toolbar = gtk.Toolbar() custom_slide_toolbar = gtk.Toolbar() custom_stator_toolbar = gtk.Toolbar() edit_toolbar = gtk.Toolbar() |
if self.sr.last is not None: data = self.sr.last.labels[0] if data is not None: clipBoard.set_text(str(data)) | if self.sr.last is None and self.sr.last.labels[0] is not None: clipBoard.set_text(self.sr.last.labels[0]) | def _copy_cb(self, arg=None): """ Copy a number to the clipboard from the active slide. """ clipBoard = gtk.Clipboard() if self.sr.last is not None: data = self.sr.last.labels[0] if data is not None: clipBoard.set_text(str(data)) return |
def _show_slides(self, top, bottom, function): | def _show_slides(self, slide, stator, function): | def _show_slides(self, top, bottom, function): self._hide_all() self._top_combo.set_active(_SLIDES.index(top)) self.set_slide() self._bottom_combo.set_active(_STATORS.index(bottom)) self.set_stator() self._function_combo.set_active(_FUNCTIONS.index(function)) self.sr.update_slide_labels() self.sr.update_results_label() |
self._top_combo.set_active(_SLIDES.index(top)) | self._slide_combo.set_active(_SLIDES.index(slide)) | def _show_slides(self, top, bottom, function): self._hide_all() self._top_combo.set_active(_SLIDES.index(top)) self.set_slide() self._bottom_combo.set_active(_STATORS.index(bottom)) self.set_stator() self._function_combo.set_active(_FUNCTIONS.index(function)) self.sr.update_slide_labels() self.sr.update_results_label() |
self._bottom_combo.set_active(_STATORS.index(bottom)) | self._stator_combo.set_active(_STATORS.index(stator)) | def _show_slides(self, top, bottom, function): self._hide_all() self._top_combo.set_active(_SLIDES.index(top)) self.set_slide() self._bottom_combo.set_active(_STATORS.index(bottom)) self.set_stator() self._function_combo.set_active(_FUNCTIONS.index(function)) self.sr.update_slide_labels() self.sr.update_results_label() |
self._show_slides(_L, _L2, _FL) | self._show_slides(_L, _L, _FL) | def show_l(self): """ linear scale """ self.sr.active_slide = self.sr.name_to_slide('L') self.sr.active_stator = self.sr.name_to_stator('L2') self._show_slides(_L, _L2, _FL) |
def _top_combo_cb(self, arg=None): | def _slide_combo_cb(self, arg=None): | def _top_combo_cb(self, arg=None): """ Read value from slide combo box """ _top_dictionary = {_C: 'C', _CI: 'CI', _A: 'A', _K: 'K', _S: 'S', _T: 'T', _L: 'L', _LL0: 'LL0', _LLn: 'LLn', _UD: 'custom'} self.sr.active_slide = self.sr.name_to_slide(_top_dictionary[ _SLIDES[self._top_combo.get_active()]]) function = self._predefined_function() if function is not None: function() else: self._function_combo.set_active(_FUNCTIONS.index(_UK)) self.set_slide() self.sr.update_slide_labels() self.sr.update_results_label() |
_SLIDES[self._top_combo.get_active()]]) | _SLIDES[self._slide_combo.get_active()]]) | def _top_combo_cb(self, arg=None): """ Read value from slide combo box """ _top_dictionary = {_C: 'C', _CI: 'CI', _A: 'A', _K: 'K', _S: 'S', _T: 'T', _L: 'L', _LL0: 'LL0', _LLn: 'LLn', _UD: 'custom'} self.sr.active_slide = self.sr.name_to_slide(_top_dictionary[ _SLIDES[self._top_combo.get_active()]]) function = self._predefined_function() if function is not None: function() else: self._function_combo.set_active(_FUNCTIONS.index(_UK)) self.set_slide() self.sr.update_slide_labels() self.sr.update_results_label() |
def _bottom_combo_cb(self, arg=None): | def _stator_combo_cb(self, arg=None): | def _bottom_combo_cb(self, arg=None): """ Read value from stator combo box """ _bottom_dictionary = {_D: 'D', _DI: 'DI', _L: 'L2', _B: 'B', _K: 'K2', _S: 'S2', _T: 'T2', _LL0: 'LL02', _LLn: 'LLn2', _UD: 'custom2'} self.sr.active_stator = self.sr.name_to_stator(_bottom_dictionary[ _STATORS[self._bottom_combo.get_active()]]) function = self._predefined_function() if function is not None: function() else: self._function_combo.set_active(_FUNCTIONS.index(_UK)) self.set_stator() self.sr.update_slide_labels() self.sr.update_results_label() |
_STATORS[self._bottom_combo.get_active()]]) | _STATORS[self._stator_combo.get_active()]]) | def _bottom_combo_cb(self, arg=None): """ Read value from stator combo box """ _bottom_dictionary = {_D: 'D', _DI: 'DI', _L: 'L2', _B: 'B', _K: 'K2', _S: 'S2', _T: 'T2', _LL0: 'LL02', _LLn: 'LLn2', _UD: 'custom2'} self.sr.active_stator = self.sr.name_to_stator(_bottom_dictionary[ _STATORS[self._bottom_combo.get_active()]]) function = self._predefined_function() if function is not None: function() else: self._function_combo.set_active(_FUNCTIONS.index(_UK)) self.set_stator() self.sr.update_slide_labels() self.sr.update_results_label() |
self._top_combo = _combo_factory(_SLIDES, _C, _('slides'), self._top_combo_cb, | self._slide_combo = _combo_factory(_SLIDES, _C, _('slides'), self._slide_combo_cb, | def _setup_toolbars(self, have_toolbox): """ Setup the toolbars.. """ |
self._bottom_combo = _combo_factory(_STATORS, _D, _('stators'), self._bottom_combo_cb, project_toolbar) | self._stator_combo = _combo_factory(_STATORS, _D, _('stators'), self._stator_combo_cb, project_toolbar) | def _setup_toolbars(self, have_toolbox): """ Setup the toolbars.. """ |
list = self.list | list = self.list[:] | def find_sprite(self, pos): list = self.list list.reverse() for spr in list: if spr.hit(pos): return spr return None |
if self.sr.last is None and self.sr.last.labels[0] is not None: | if self.sr.last is not None and self.sr.last.labels[0] is not None: | def _copy_cb(self, arg=None): """ Copy a number to the clipboard from the active slide. """ clipBoard = gtk.Clipboard() if self.sr.last is None and self.sr.last.labels[0] is not None: clipBoard.set_text(self.sr.last.labels[0]) return |
self.parent._min_entry.set_text('NaN') | self.parent._domain_min[slide].set_text('NaN') | def make_custom_slide(self, offset_text, label_text, calculate_text, min_text, max_text, step_text, slide): """ Create custom slide and stator from text entered on toolbar. """ try: min_value = float(min_text) except ValueError: self.parent._min_entry.set_text('NaN') return try: max_value = float(max_text) except ValueError: self.parent._max_entry.set_text('NaN') return try: step_value = float(step_text) except ValueError: self.parent._step_entry.set_text('NaN') return |
self.parent._max_entry.set_text('NaN') | self.parent._domain_max[slide].set_text('NaN') | def make_custom_slide(self, offset_text, label_text, calculate_text, min_text, max_text, step_text, slide): """ Create custom slide and stator from text entered on toolbar. """ try: min_value = float(min_text) except ValueError: self.parent._min_entry.set_text('NaN') return try: max_value = float(max_text) except ValueError: self.parent._max_entry.set_text('NaN') return try: step_value = float(step_text) except ValueError: self.parent._step_entry.set_text('NaN') return |
self.parent._step_entry.set_text('NaN') | self.parent._step_size[slide].set_text('NaN') | def make_custom_slide(self, offset_text, label_text, calculate_text, min_text, max_text, step_text, slide): """ Create custom slide and stator from text entered on toolbar. """ try: min_value = float(min_text) except ValueError: self.parent._min_entry.set_text('NaN') return try: max_value = float(max_text) except ValueError: self.parent._max_entry.set_text('NaN') return try: step_value = float(step_text) except ValueError: self.parent._step_entry.set_text('NaN') return |
scale *= float(SWIDTH - 2 * OFFSET) / SCALE | def mark(self, offset, height3, height2, height1, string=None, flip=False, scale=1.0): """ Plot marks in a range from 1 to 10 along the length of the slide """ svg = '' scale *= float(SWIDTH - 2 * OFFSET) / SCALE if flip: ln = (log10 - offset) * SCALE * scale + OFFSET else: ln = offset * SCALE * scale + OFFSET if string is not None: svg += ' <text style="font-size:12px;fill:#000000;">\n' svg += ' <tspan\n' svg += ' x="%0.2f"\n' % (ln) svg += ' y="%d"\n' % (height3) svg += ' style="font-size:12px;text-align:center;text-anchor:middle;font-family:Bitstream Vera Sans;">%0.1f</tspan></text>\n' % (string) svg += ' <path\n' svg += ' d="M %0.2f,%d,%0.2f,%d"\n' % (ln, height1, ln, height2) svg += ' style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1" />\n' return svg |
|
ln = (log10 - offset) * SCALE * scale + OFFSET else: ln = offset * SCALE * scale + OFFSET | log = (log10 - offset) * SCALE * scale + OFFSET else: log = offset * SCALE * scale + OFFSET | def mark(self, offset, height3, height2, height1, string=None, flip=False, scale=1.0): """ Plot marks in a range from 1 to 10 along the length of the slide """ svg = '' scale *= float(SWIDTH - 2 * OFFSET) / SCALE if flip: ln = (log10 - offset) * SCALE * scale + OFFSET else: ln = offset * SCALE * scale + OFFSET if string is not None: svg += ' <text style="font-size:12px;fill:#000000;">\n' svg += ' <tspan\n' svg += ' x="%0.2f"\n' % (ln) svg += ' y="%d"\n' % (height3) svg += ' style="font-size:12px;text-align:center;text-anchor:middle;font-family:Bitstream Vera Sans;">%0.1f</tspan></text>\n' % (string) svg += ' <path\n' svg += ' d="M %0.2f,%d,%0.2f,%d"\n' % (ln, height1, ln, height2) svg += ' style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1" />\n' return svg |
svg += ' x="%0.2f"\n' % (ln) | svg += ' x="%0.2f"\n' % (log) | def mark(self, offset, height3, height2, height1, string=None, flip=False, scale=1.0): """ Plot marks in a range from 1 to 10 along the length of the slide """ svg = '' scale *= float(SWIDTH - 2 * OFFSET) / SCALE if flip: ln = (log10 - offset) * SCALE * scale + OFFSET else: ln = offset * SCALE * scale + OFFSET if string is not None: svg += ' <text style="font-size:12px;fill:#000000;">\n' svg += ' <tspan\n' svg += ' x="%0.2f"\n' % (ln) svg += ' y="%d"\n' % (height3) svg += ' style="font-size:12px;text-align:center;text-anchor:middle;font-family:Bitstream Vera Sans;">%0.1f</tspan></text>\n' % (string) svg += ' <path\n' svg += ' d="M %0.2f,%d,%0.2f,%d"\n' % (ln, height1, ln, height2) svg += ' style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1" />\n' return svg |
svg += ' d="M %0.2f,%d,%0.2f,%d"\n' % (ln, height1, ln, height2) | svg += ' d="M %0.2f,%d,%0.2f,%d"\n' % (log, height1, log, height2) | def mark(self, offset, height3, height2, height1, string=None, flip=False, scale=1.0): """ Plot marks in a range from 1 to 10 along the length of the slide """ svg = '' scale *= float(SWIDTH - 2 * OFFSET) / SCALE if flip: ln = (log10 - offset) * SCALE * scale + OFFSET else: ln = offset * SCALE * scale + OFFSET if string is not None: svg += ' <text style="font-size:12px;fill:#000000;">\n' svg += ' <tspan\n' svg += ' x="%0.2f"\n' % (ln) svg += ' y="%d"\n' % (height3) svg += ' style="font-size:12px;text-align:center;text-anchor:middle;font-family:Bitstream Vera Sans;">%0.1f</tspan></text>\n' % (string) svg += ' <path\n' svg += ' d="M %0.2f,%d,%0.2f,%d"\n' % (ln, height1, ln, height2) svg += ' style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1" />\n' return svg |
scale *= float(SWIDTH - 2 * OFFSET) / SCALE | def special_mark(self, offset, height3, height2, height1, string, flip=False, scale=1.0): """ Plot special marks, e.g., e and pi """ svg = '' scale *= float(SWIDTH - 2 * OFFSET) / SCALE if flip: ln = (log10 - offset) * SCALE * scale + OFFSET else: ln = offset * SCALE * scale + OFFSET svg += ' <text style="font-size:12px;fill:#0000ff;">\n' svg += ' <tspan\n' svg += ' x="%0.2f"\n' % (ln) svg += ' y="%d"\n' % (height3) svg += ' style="font-size:12px;text-align:center;text-anchor:middle;font-family:Bitstream Vera Sans;">%s</tspan></text>\n' % (string) svg += ' <path\n' svg += ' d="M %0.2f,%d,%0.2f,%d"\n' % (ln, height1, ln, height2) svg += ' style="fill:none;stroke:#0000ff;stroke-width:1px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1" />\n' return svg |
|
ln = (log10 - offset) * SCALE * scale + OFFSET else: ln = offset * SCALE * scale + OFFSET | log = (log10 - offset) * SCALE * scale + OFFSET else: log = offset * SCALE * scale + OFFSET | def special_mark(self, offset, height3, height2, height1, string, flip=False, scale=1.0): """ Plot special marks, e.g., e and pi """ svg = '' scale *= float(SWIDTH - 2 * OFFSET) / SCALE if flip: ln = (log10 - offset) * SCALE * scale + OFFSET else: ln = offset * SCALE * scale + OFFSET svg += ' <text style="font-size:12px;fill:#0000ff;">\n' svg += ' <tspan\n' svg += ' x="%0.2f"\n' % (ln) svg += ' y="%d"\n' % (height3) svg += ' style="font-size:12px;text-align:center;text-anchor:middle;font-family:Bitstream Vera Sans;">%s</tspan></text>\n' % (string) svg += ' <path\n' svg += ' d="M %0.2f,%d,%0.2f,%d"\n' % (ln, height1, ln, height2) svg += ' style="fill:none;stroke:#0000ff;stroke-width:1px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1" />\n' return svg |
svg += ' x="%0.2f"\n' % (ln) | svg += ' x="%0.2f"\n' % (log) | def special_mark(self, offset, height3, height2, height1, string, flip=False, scale=1.0): """ Plot special marks, e.g., e and pi """ svg = '' scale *= float(SWIDTH - 2 * OFFSET) / SCALE if flip: ln = (log10 - offset) * SCALE * scale + OFFSET else: ln = offset * SCALE * scale + OFFSET svg += ' <text style="font-size:12px;fill:#0000ff;">\n' svg += ' <tspan\n' svg += ' x="%0.2f"\n' % (ln) svg += ' y="%d"\n' % (height3) svg += ' style="font-size:12px;text-align:center;text-anchor:middle;font-family:Bitstream Vera Sans;">%s</tspan></text>\n' % (string) svg += ' <path\n' svg += ' d="M %0.2f,%d,%0.2f,%d"\n' % (ln, height1, ln, height2) svg += ' style="fill:none;stroke:#0000ff;stroke-width:1px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1" />\n' return svg |
svg += ' d="M %0.2f,%d,%0.2f,%d"\n' % (ln, height1, ln, height2) | svg += ' d="M %0.2f,%d,%0.2f,%d"\n' % (log, height1, log, height2) | def special_mark(self, offset, height3, height2, height1, string, flip=False, scale=1.0): """ Plot special marks, e.g., e and pi """ svg = '' scale *= float(SWIDTH - 2 * OFFSET) / SCALE if flip: ln = (log10 - offset) * SCALE * scale + OFFSET else: ln = offset * SCALE * scale + OFFSET svg += ' <text style="font-size:12px;fill:#0000ff;">\n' svg += ' <tspan\n' svg += ' x="%0.2f"\n' % (ln) svg += ' y="%d"\n' % (height3) svg += ' style="font-size:12px;text-align:center;text-anchor:middle;font-family:Bitstream Vera Sans;">%s</tspan></text>\n' % (string) svg += ' <path\n' svg += ' d="M %0.2f,%d,%0.2f,%d"\n' % (ln, height1, ln, height2) svg += ' style="fill:none;stroke:#0000ff;stroke-width:1px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1" />\n' return svg |
scale *= float(SWIDTH - 2 * OFFSET) / SCALE | def mark(self, offset, height3, height2, height1, string=None, flip=False, scale=1.0): """ Plot marks in a range from 1 to 10 along the length of the slide """ svg = '' scale *= float(SWIDTH - 2 * OFFSET) / SCALE if flip: ln = (log10 - offset) * SCALE * scale + OFFSET else: ln = offset * SCALE * scale + OFFSET if string is not None: svg += ' <text style="font-size:12px;fill:#000000;">\n' svg += ' <tspan\n' svg += ' x="%0.2f"\n' % (ln) svg += ' y="%d"\n' % (height3) svg += ' style="font-size:12px;text-align:center;text-anchor:middle;font-family:Bitstream Vera Sans;">%d</tspan></text>\n' % (int(string)) svg += ' <path\n' svg += ' d="M %0.2f,%d,%0.2f,%d"\n' % (ln, height1, ln, height2) svg += ' style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1" />\n' return svg |
|
scale *= float(SWIDTH - 2 * OFFSET) / SCALE | def mark(self, offset, height3, height2, height1, string=None, flip=False, scale=1.0): """ Plot marks in a range from 1 to 10 along the length of the slide """ svg = '' scale *= float(SWIDTH - 2 * OFFSET) / SCALE if flip: ln = (log10 - offset) * SCALE * scale + OFFSET else: ln = offset * SCALE * scale + OFFSET if string is not None: svg += ' <text style="font-size:12px;fill:#000000;">\n' svg += ' <tspan\n' svg += ' x="%0.2f"\n' % (ln) svg += ' y="%d"\n' % (height3) svg += ' style="font-size:12px;text-align:center;text-anchor:middle;font-family:Bitstream Vera Sans;">%0.4f</tspan></text>\n' % (string) svg += ' <path\n' svg += ' d="M %0.2f,%d,%0.2f,%d"\n' % (ln, height1, ln, height2) svg += ' style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1" />\n' return svg |
|
return math.exp(x / 1000.) | return math.pow(10, x / 1000.) | def label_function(x): return math.exp(x / 1000.) |
y = math.pow(10, precision) | y = pow(10, precision) | def round(x, precision=2): if precision == 2: return(float(int(x * 100 + 0.5) / 100.)) elif precision == 1: return(float(int(x * 10 + 0.5) / 10.)) elif precision == 0: return(int(x + 0.5)) else: y = math.pow(10, precision) return(float(int(x * y + 0.5) / y)) |
return round(math.exp(dx / SCALE) * rescale) | return round(exp(dx / SCALE) * rescale) | def _calc_log(dx): """ C and D scales """ rescale = 1 if dx < 0: rescale = 0.1 dx += SWIDTH - (2.0 * OFFSET) return round(math.exp(dx / SCALE) * rescale) |
return round(10.0/ math.exp(dx / SCALE) * rescale) | return round(10.0 / exp(dx / SCALE) * rescale) | def _calc_inverse_log(dx): """ CI and DI scales """ rescale = 1 if dx < 0: rescale = 0.1 dx += SWIDTH - (2.0 * OFFSET) return round(10.0/ math.exp(dx / SCALE) * rescale) |
A = math.exp(2 * dx / SCALE) * rescale | A = exp(2 * dx / SCALE) * rescale | def _calc_log_squared(dx): """ A and B scales """ rescale = 1 if dx < 0: dx += SWIDTH - (2.0 * OFFSET) rescale = 0.01 A = math.exp(2 * dx / SCALE) * rescale if A > 50: return round(A, 1) else: return round(A) |
K = math.exp(3 * dx / SCALE) * rescale | K = exp(3 * dx / SCALE) * rescale | def _calc_log_cubed(dx): """ K scale """ rescale = 1 if dx < 0: rescale = 0.001 dx += SWIDTH - (2.0 * OFFSET) K = math.exp(3 * dx / SCALE) * rescale if K > 500: return round(K, 0) elif K > 50: return round(K, 1) else: return round(K) |
LL0 = math.exp(math.exp(dx / SCALE) / 1000) | LL0 = exp(exp(dx / SCALE) / 1000) | def _calc_log_log(dx): """ LL0 scale """ if dx < 0: dx += SWIDTH - (2.0 * OFFSET) LL0 = math.exp(math.exp(dx / SCALE) / 1000) if LL0 > 1.002: return round(LL0, 5) else: return round(LL0, 6) |
return round(10 * ((dx / SCALE) / math.log(10) - 1.0)) | return round(10 * ((dx / SCALE) / log(10) - 1.0)) | def _calc_linear(dx): """ L scale """ if dx < 0: dx += SWIDTH - (2.0 * OFFSET) return round(10 * ((dx / SCALE) / math.log(10) - 1.0)) else: return round(10 * (dx / SCALE) / math.log(10)) |
return round(10 * (dx / SCALE) / math.log(10)) | return round(10 * (dx / SCALE) / log(10)) | def _calc_linear(dx): """ L scale """ if dx < 0: dx += SWIDTH - (2.0 * OFFSET) return round(10 * ((dx / SCALE) / math.log(10) - 1.0)) else: return round(10 * (dx / SCALE) / math.log(10)) |
s = math.exp(dx)/10 | s = exp(dx)/10 | def _calc_sine(dx): """ S scale """ dx /= SCALE s = math.exp(dx)/10 if s > 1.0: s = 1.0 S = 180.0 * math.asin(s) / math.pi if S > 60: return round(S, 1) else: return round(S) |
S = 180.0 * math.asin(s) / math.pi | S = 180.0 * asin(s) / pi | def _calc_sine(dx): """ S scale """ dx /= SCALE s = math.exp(dx)/10 if s > 1.0: s = 1.0 S = 180.0 * math.asin(s) / math.pi if S > 60: return round(S, 1) else: return round(S) |
t = math.exp(dx)/10 | t = exp(dx)/10 | def _calc_tangent(dx): """ T scale """ dx /= SCALE t = math.exp(dx)/10 if t > 1.0: t = 1.0 return round(180.0 * math.atan(t) / math.pi) |
return round(180.0 * math.atan(t) / math.pi) | return round(180.0 * atan(t) / pi) | def _calc_tangent(dx): """ T scale """ dx /= SCALE t = math.exp(dx)/10 if t > 1.0: t = 1.0 return round(180.0 * math.atan(t) / math.pi) |
600, SHEIGHT) | 800, SHEIGHT) | def __init__(self, canvas, path, parent=None): """ Handle launch from both within and without of Sugar environment. """ SLIDES = {'C':[C_slide, self._calc_C], 'CI':[CI_slide, self._calc_CI], 'A':[A_slide, self._calc_A], 'K':[K_slide, self._calc_K], 'S':[S_slide, self._calc_S], 'T':[T_slide, self._calc_T], 'L':[L_slide, self._calc_L], 'LLn':[LLn_slide, self._calc_LLn], 'LL0':[LL0_slide, self._calc_LL0]} |
self.make_custom_slide('math.log(x, 10)', 'x', 'math.exp(x)', 1, 10, 1) | self.make_custom_slide('log(x, 10)', 'x', 'exp(x)', 1, 10, 1) | def __init__(self, canvas, path, parent=None): """ Handle launch from both within and without of Sugar environment. """ SLIDES = {'C':[C_slide, self._calc_C], 'CI':[CI_slide, self._calc_CI], 'A':[A_slide, self._calc_A], 'K':[K_slide, self._calc_K], 'S':[S_slide, self._calc_S], 'T':[T_slide, self._calc_T], 'L':[L_slide, self._calc_L], 'LLn':[LLn_slide, self._calc_LLn], 'LL0':[LL0_slide, self._calc_LL0]} |
if k == 'a': | if k in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'period', 'minus', 'Return', 'BackSpace']: if self.reticule.match(self.last): if self.last == self.reticule.tabs[TOP].spr: self._process_numeric_input(self.last, k) elif k == 'a': | def _keypress_cb(self, area, event): """ Keypress: moving the slides with the arrow keys """ k = gtk.gdk.keyval_name(event.keyval) if self.parent == None: return if k == 'a': self.parent.show_a() elif k == 'k': self.parent.show_k() elif k == 'c' or k == 'asterisk' or k == 'x': self.parent.show_c() elif k == 'i': self.parent.show_ci() elif k == 's': self.parent.show_s() elif k == 't': self.parent.show_t() elif k == 'l' or k == 'plus': self.parent.show_l() elif k == 'Left' or k == 'comma': self._move_slides(self.last, -1) elif k == 'Right' or k == 'period': self._move_slides(self.last, 1) elif k == 'Home' or k == 'Pause': self._move_slides(self.name_to_stator('D').spr, -self.name_to_stator('D').spr.get_xy()[0]) elif k == 'r': self.reticule.move(150, self.reticule.spr.get_xy()[1]) self.update_slide_labels() self.update_results_label() elif k == 'Return' or k == 'BackSpace': self.parent.realign_cb() self.reticule.move(150, self.reticule.spr.get_xy()[1]) self.update_slide_labels() self.update_results_label() return True |
elif k == 'Left' or k == 'comma': self._move_slides(self.last, -1) elif k == 'Right' or k == 'period': self._move_slides(self.last, 1) elif k == 'Home' or k == 'Pause': | elif k == 'Left' or k == 'less': if self.last is not None: self._move_slides(self.last, -1) elif k == 'Right' or k == 'greater': if self.last is not None: self._move_slides(self.last, 1) elif k == 'Home' or k == 'Pause' or k == 'Up': | def _keypress_cb(self, area, event): """ Keypress: moving the slides with the arrow keys """ k = gtk.gdk.keyval_name(event.keyval) if self.parent == None: return if k == 'a': self.parent.show_a() elif k == 'k': self.parent.show_k() elif k == 'c' or k == 'asterisk' or k == 'x': self.parent.show_c() elif k == 'i': self.parent.show_ci() elif k == 's': self.parent.show_s() elif k == 't': self.parent.show_t() elif k == 'l' or k == 'plus': self.parent.show_l() elif k == 'Left' or k == 'comma': self._move_slides(self.last, -1) elif k == 'Right' or k == 'period': self._move_slides(self.last, 1) elif k == 'Home' or k == 'Pause': self._move_slides(self.name_to_stator('D').spr, -self.name_to_stator('D').spr.get_xy()[0]) elif k == 'r': self.reticule.move(150, self.reticule.spr.get_xy()[1]) self.update_slide_labels() self.update_results_label() elif k == 'Return' or k == 'BackSpace': self.parent.realign_cb() self.reticule.move(150, self.reticule.spr.get_xy()[1]) self.update_slide_labels() self.update_results_label() return True |
elif k == 'Return' or k == 'BackSpace': | elif k == 'Down': | def _keypress_cb(self, area, event): """ Keypress: moving the slides with the arrow keys """ k = gtk.gdk.keyval_name(event.keyval) if self.parent == None: return if k == 'a': self.parent.show_a() elif k == 'k': self.parent.show_k() elif k == 'c' or k == 'asterisk' or k == 'x': self.parent.show_c() elif k == 'i': self.parent.show_ci() elif k == 's': self.parent.show_s() elif k == 't': self.parent.show_t() elif k == 'l' or k == 'plus': self.parent.show_l() elif k == 'Left' or k == 'comma': self._move_slides(self.last, -1) elif k == 'Right' or k == 'period': self._move_slides(self.last, 1) elif k == 'Home' or k == 'Pause': self._move_slides(self.name_to_stator('D').spr, -self.name_to_stator('D').spr.get_xy()[0]) elif k == 'r': self.reticule.move(150, self.reticule.spr.get_xy()[1]) self.update_slide_labels() self.update_results_label() elif k == 'Return' or k == 'BackSpace': self.parent.realign_cb() self.reticule.move(150, self.reticule.spr.get_xy()[1]) self.update_slide_labels() self.update_results_label() return True |
min = float(min_text) | min_value = float(min_text) | def make_custom_slide(self, offset_text, label_text, calculate_text, min_text, max_text, step_text): """ Create custom slide and stator from text entered on toolbar. """ try: min = float(min_text) except ValueError: self.parent._min_entry.set_text('NaN') return try: max = float(max_text) except ValueError: self.parent._max_entry.set_text('NaN') return try: step = float(step_text) except ValueError: self.parent._step_entry.set_text('NaN') return |
max = float(max_text) | max_value = float(max_text) | def make_custom_slide(self, offset_text, label_text, calculate_text, min_text, max_text, step_text): """ Create custom slide and stator from text entered on toolbar. """ try: min = float(min_text) except ValueError: self.parent._min_entry.set_text('NaN') return try: max = float(max_text) except ValueError: self.parent._max_entry.set_text('NaN') return try: step = float(step_text) except ValueError: self.parent._step_entry.set_text('NaN') return |
step = float(step_text) | step_value = float(step_text) | def make_custom_slide(self, offset_text, label_text, calculate_text, min_text, max_text, step_text): """ Create custom slide and stator from text entered on toolbar. """ try: min = float(min_text) except ValueError: self.parent._min_entry.set_text('NaN') return try: max = float(max_text) except ValueError: self.parent._max_entry.set_text('NaN') return try: step = float(step_text) except ValueError: self.parent._step_entry.set_text('NaN') return |
self._calc_custom, custom_offset_function, custom_label_function, min, max, step) | self._calc_custom, custom_offset_function, custom_label_function, min_value, max_value, step_value) | myf = "def f(x): return " + label_text.replace('import','') |
custom_label_function, min, max, step) | custom_label_function, min_value, max_value, step_value) | myf = "def f(x): return " + label_text.replace('import','') |
v_right = round(math.log(10)) + v_left | v_right = round(log(10)) + v_left | def _update_top(self, function): v_left = function() if self.active_stator.name == 'L2': v_right = 10 + v_left elif self.active_stator.name == 'D': v_right = v_left * 10. elif self.active_stator.name == 'B': v_right = v_left * 100. elif self.active_stator.name == 'K2': v_right = v_left * 1000. elif self.active_stator.name == 'DI': v_right = v_left / 10. elif self.active_stator.name == 'LLn2': v_right = round(math.log(10)) + v_left else: v_right = v_left for slide in self.slides: slide.tabs[LEFT].spr.set_label(str(v_left)) slide.tabs[RIGHT].spr.set_label(str(v_right)) |
'ch': { 'title': u'中文 - 0%' }, | def header(): c.slackslog = request.POST if ('submit' in request.POST and request.POST['submit'] == _gettext('Search')): redirect( url( controller = 'root', action = 'template', templatefile = 'docs', parameter1 = request.POST['search'].replace(' ', '').lower() ), code = 303 ) c.loop.languages = { 'ch': { 'title': u'中文 - 0%' }, 'es': { 'title': u'Español - 0%' }, 'fr': { 'title': u'Français - 0%' }, 'pl': { 'title': u'Polski - 0%' } } if ( 'language' in request.POST and ( request.POST['language'] in c.loop.languages or request.POST['language'] == '' ) ): session['lang'] = request.POST['language'] session.save() c.loop.languages['ch']['selected'] = True if 'lang' in session: set_lang(session['lang']) for value in c.loop.languages.items(): c.loop.languages[value[0]]['selected'] = (get_lang() and get_lang()[0] == value[0]) return '' |
|
}, 'pl': { 'title': u'Polski - 0%' | def header(): c.slackslog = request.POST if ('submit' in request.POST and request.POST['submit'] == _gettext('Search')): redirect( url( controller = 'root', action = 'template', templatefile = 'docs', parameter1 = request.POST['search'].replace(' ', '').lower() ), code = 303 ) c.loop.languages = { 'ch': { 'title': u'中文 - 0%' }, 'es': { 'title': u'Español - 0%' }, 'fr': { 'title': u'Français - 0%' }, 'pl': { 'title': u'Polski - 0%' } } if ( 'language' in request.POST and ( request.POST['language'] in c.loop.languages or request.POST['language'] == '' ) ): session['lang'] = request.POST['language'] session.save() c.loop.languages['ch']['selected'] = True if 'lang' in session: set_lang(session['lang']) for value in c.loop.languages.items(): c.loop.languages[value[0]]['selected'] = (get_lang() and get_lang()[0] == value[0]) return '' |
|
return escape(json.dumps(string, sort_keys=True, indent=4)) | return json.dumps(string, sort_keys=True, indent=4) | def format(string): string = templating.getvariable(string, '.', c) return escape(json.dumps(string, sort_keys=True, indent=4)) |
}, { 'title': 'try', 'url': 'try' }, { 'title': 'return', 'url': 'return' }, { 'title': 'trim', 'url': 'trim' | def docs(): c.loop.articles = [ { 'articles': [ { 'title': 'Getting Started', 'url': 'gettingstarted' }, { 'title': 'Comparison of SUIT to its Alternatives', 'url': 'comparison' }, { 'title': 'Features', 'url': 'features' }, { 'title': 'Reading Docs', 'url': 'readingdocs' }, { 'title': 'Rules', 'url': 'rules' }, { 'title': 'Rules Vs. Functions', 'url': 'rulesvsfunctions' }, { 'title': 'Attributes', 'url': 'attributes' }, { 'title': 'Escaping', 'url': 'escaping' }, { 'title': 'FAQ', 'url': 'faq' }, { 'title': 'History', 'url': 'history' }, { 'title': 'Changelog', 'url': 'changelog' }, { 'title': 'Credits', 'url': 'credits' } ], 'title': 'General', 'url': 'general' }, { 'articles': [ { 'title': 'execute', 'url': 'execute' }, { 'title': 'tokens', 'url': 'tokens' }, { 'title': 'parse', 'url': 'parse' }, { 'title': 'walk', 'url': 'walk' } ], 'title': 'SUIT Functions', 'url': 'suitfunctions' }, { 'articles': [ { 'title': 'SUIT Construct', 'url': 'suitconstruct' }, { 'title': 'Templating Construct', 'url': 'templatingconstruct' }, { 'title': 'BBCode Construct', 'url': 'bbcodeconstruct' } ], 'title': 'Constructs', 'url': 'constructs' }, { 'articles': [ { 'title': 'defaultconfig', 'url': 'defaultconfig' } ], 'title': 'Helper Functions', 'url': 'helperfunctions' }, { 'articles': [ { 'title': 'var', 'url': 'var' }, { 'title': 'if', 'url': 'if' }, { 'title': 'loop', 'url': 'loop' }, { 'title': 'comment', 'url': 'comment' }, { 'title': 'template', 'url': 'template' }, { 'title': 'execute (Templating Rule)', 'url': 'executetemplatingrule' }, { 'title': 'assign', 'url': 'assign' }, { 'title': 'entities', 'url': 'entities' }, { 'title': 'skip', 'url': 'skip' }, { 'title': 'call', 'url': 'call' }, { 'title': 'transform', 'url': 'transform' }, { 'title': 'local', 'url': 'local' }, { 'title': 'try', 'url': 'try' }, { 'title': 'return', 'url': 'return' }, { 'title': 'trim', 'url': 'trim' }, { 'title': 'bracket', 'url': 'bracket' } ], 'title': 'Templating Rules', 'url': 'templatingrules' }, { 'articles': [ { 'title': 'c', 'url': 'c' }, { 'title': 'template (SUITlons Rule)', 'url': 'templatesuitlonsrule' }, { 'title': 'gettext', 'url': 'gettext' }, { 'title': 'url', 'url': 'url' } ], 'title': 'SUITlons Rules', 'url': 'suitlonsrules' }, { 'articles': [], 'title': 'BBCode Rules', 'url': 'bbcoderules' }, { 'articles': [], 'title': 'Helper Functions', 'url': 'helperfunctions' }, { 'articles': [ { 'title': 'SLACKS', 'url': 'slacks' } ], 'title': 'Subprojects', 'url': 'subprojects' } ] c.condition.notfound = False c.condition.article = False c.condition.index = False c.condition.matches = False if not c.parameter1: c.condition.index = True elif os.path.isfile( os.path.join( config['pylons.paths']['templates'], 'docs', os.path.normpath(c.parameter1.lower()) + '.tpl' ) ): for category in c.loop.articles: for article in category['articles']: if c.parameter1 == article['url']: c.article = article['title'] c.condition.article = True break if c.parameter1 and not c.condition.article: c.loop.search = [] for category in c.loop.articles: for article in category['articles']: if article['title'].lower().find(c.parameter1.lower()) != -1: c.loop.search.append(article) c.condition.notfound = True c.condition.matches = (c.loop.search) return '' |
|
'articles': [], | 'articles': [ { 'title': 'b', 'url': 'b' }, { 'title': 'i', 'url': 'i' }, { 'title': 'u', 'url': 'u' }, { 'title': 's', 'url': 's' }, { 'title': 'url (BBCode Rule)', 'url': 'urlbbcoderule' }, { 'title': 'email', 'url': 'email' }, { 'title': 'img', 'url': 'img' }, { 'title': 'size', 'url': 'size' }, { 'title': 'font', 'url': 'font' }, { 'title': 'color', 'url': 'color' }, { 'title': 'align', 'url': 'align' }, { 'title': 'list', 'url': 'list' }, { 'title': 'quote', 'url': 'quote' }, { 'title': 'code', 'url': 'code' } ], | def docs(): c.loop.articles = [ { 'articles': [ { 'title': 'Getting Started', 'url': 'gettingstarted' }, { 'title': 'Comparison of SUIT to its Alternatives', 'url': 'comparison' }, { 'title': 'Features', 'url': 'features' }, { 'title': 'Reading Docs', 'url': 'readingdocs' }, { 'title': 'Rules', 'url': 'rules' }, { 'title': 'Rules Vs. Functions', 'url': 'rulesvsfunctions' }, { 'title': 'Attributes', 'url': 'attributes' }, { 'title': 'Escaping', 'url': 'escaping' }, { 'title': 'FAQ', 'url': 'faq' }, { 'title': 'History', 'url': 'history' }, { 'title': 'Changelog', 'url': 'changelog' }, { 'title': 'Credits', 'url': 'credits' } ], 'title': 'General', 'url': 'general' }, { 'articles': [ { 'title': 'execute', 'url': 'execute' }, { 'title': 'tokens', 'url': 'tokens' }, { 'title': 'parse', 'url': 'parse' }, { 'title': 'walk', 'url': 'walk' } ], 'title': 'SUIT Functions', 'url': 'suitfunctions' }, { 'articles': [ { 'title': 'SUIT Construct', 'url': 'suitconstruct' }, { 'title': 'Templating Construct', 'url': 'templatingconstruct' }, { 'title': 'BBCode Construct', 'url': 'bbcodeconstruct' } ], 'title': 'Constructs', 'url': 'constructs' }, { 'articles': [ { 'title': 'defaultconfig', 'url': 'defaultconfig' } ], 'title': 'Helper Functions', 'url': 'helperfunctions' }, { 'articles': [ { 'title': 'var', 'url': 'var' }, { 'title': 'if', 'url': 'if' }, { 'title': 'loop', 'url': 'loop' }, { 'title': 'comment', 'url': 'comment' }, { 'title': 'template', 'url': 'template' }, { 'title': 'execute (Templating Rule)', 'url': 'executetemplatingrule' }, { 'title': 'assign', 'url': 'assign' }, { 'title': 'entities', 'url': 'entities' }, { 'title': 'skip', 'url': 'skip' }, { 'title': 'call', 'url': 'call' }, { 'title': 'transform', 'url': 'transform' }, { 'title': 'local', 'url': 'local' }, { 'title': 'try', 'url': 'try' }, { 'title': 'return', 'url': 'return' }, { 'title': 'trim', 'url': 'trim' }, { 'title': 'bracket', 'url': 'bracket' } ], 'title': 'Templating Rules', 'url': 'templatingrules' }, { 'articles': [ { 'title': 'c', 'url': 'c' }, { 'title': 'template (SUITlons Rule)', 'url': 'templatesuitlonsrule' }, { 'title': 'gettext', 'url': 'gettext' }, { 'title': 'url', 'url': 'url' } ], 'title': 'SUITlons Rules', 'url': 'suitlonsrules' }, { 'articles': [], 'title': 'BBCode Rules', 'url': 'bbcoderules' }, { 'articles': [], 'title': 'Helper Functions', 'url': 'helperfunctions' }, { 'articles': [ { 'title': 'SLACKS', 'url': 'slacks' } ], 'title': 'Subprojects', 'url': 'subprojects' } ] c.condition.notfound = False c.condition.article = False c.condition.index = False c.condition.matches = False if not c.parameter1: c.condition.index = True elif os.path.isfile( os.path.join( config['pylons.paths']['templates'], 'docs', os.path.normpath(c.parameter1.lower()) + '.tpl' ) ): for category in c.loop.articles: for article in category['articles']: if c.parameter1 == article['url']: c.article = article['title'] c.condition.article = True break if c.parameter1 and not c.condition.article: c.loop.search = [] for category in c.loop.articles: for article in category['articles']: if article['title'].lower().find(c.parameter1.lower()) != -1: c.loop.search.append(article) c.condition.notfound = True c.condition.matches = (c.loop.search) return '' |
'articles': [], 'title': 'Helper Functions', 'url': 'helperfunctions' }, { | def docs(): c.loop.articles = [ { 'articles': [ { 'title': 'Getting Started', 'url': 'gettingstarted' }, { 'title': 'Comparison of SUIT to its Alternatives', 'url': 'comparison' }, { 'title': 'Features', 'url': 'features' }, { 'title': 'Reading Docs', 'url': 'readingdocs' }, { 'title': 'Rules', 'url': 'rules' }, { 'title': 'Rules Vs. Functions', 'url': 'rulesvsfunctions' }, { 'title': 'Attributes', 'url': 'attributes' }, { 'title': 'Escaping', 'url': 'escaping' }, { 'title': 'FAQ', 'url': 'faq' }, { 'title': 'History', 'url': 'history' }, { 'title': 'Changelog', 'url': 'changelog' }, { 'title': 'Credits', 'url': 'credits' } ], 'title': 'General', 'url': 'general' }, { 'articles': [ { 'title': 'execute', 'url': 'execute' }, { 'title': 'tokens', 'url': 'tokens' }, { 'title': 'parse', 'url': 'parse' }, { 'title': 'walk', 'url': 'walk' } ], 'title': 'SUIT Functions', 'url': 'suitfunctions' }, { 'articles': [ { 'title': 'SUIT Construct', 'url': 'suitconstruct' }, { 'title': 'Templating Construct', 'url': 'templatingconstruct' }, { 'title': 'BBCode Construct', 'url': 'bbcodeconstruct' } ], 'title': 'Constructs', 'url': 'constructs' }, { 'articles': [ { 'title': 'defaultconfig', 'url': 'defaultconfig' } ], 'title': 'Helper Functions', 'url': 'helperfunctions' }, { 'articles': [ { 'title': 'var', 'url': 'var' }, { 'title': 'if', 'url': 'if' }, { 'title': 'loop', 'url': 'loop' }, { 'title': 'comment', 'url': 'comment' }, { 'title': 'template', 'url': 'template' }, { 'title': 'execute (Templating Rule)', 'url': 'executetemplatingrule' }, { 'title': 'assign', 'url': 'assign' }, { 'title': 'entities', 'url': 'entities' }, { 'title': 'skip', 'url': 'skip' }, { 'title': 'call', 'url': 'call' }, { 'title': 'transform', 'url': 'transform' }, { 'title': 'local', 'url': 'local' }, { 'title': 'try', 'url': 'try' }, { 'title': 'return', 'url': 'return' }, { 'title': 'trim', 'url': 'trim' }, { 'title': 'bracket', 'url': 'bracket' } ], 'title': 'Templating Rules', 'url': 'templatingrules' }, { 'articles': [ { 'title': 'c', 'url': 'c' }, { 'title': 'template (SUITlons Rule)', 'url': 'templatesuitlonsrule' }, { 'title': 'gettext', 'url': 'gettext' }, { 'title': 'url', 'url': 'url' } ], 'title': 'SUITlons Rules', 'url': 'suitlonsrules' }, { 'articles': [], 'title': 'BBCode Rules', 'url': 'bbcoderules' }, { 'articles': [], 'title': 'Helper Functions', 'url': 'helperfunctions' }, { 'articles': [ { 'title': 'SLACKS', 'url': 'slacks' } ], 'title': 'Subprojects', 'url': 'subprojects' } ] c.condition.notfound = False c.condition.article = False c.condition.index = False c.condition.matches = False if not c.parameter1: c.condition.index = True elif os.path.isfile( os.path.join( config['pylons.paths']['templates'], 'docs', os.path.normpath(c.parameter1.lower()) + '.tpl' ) ): for category in c.loop.articles: for article in category['articles']: if c.parameter1 == article['url']: c.article = article['title'] c.condition.article = True break if c.parameter1 and not c.condition.article: c.loop.search = [] for category in c.loop.articles: for article in category['articles']: if article['title'].lower().find(c.parameter1.lower()) != -1: c.loop.search.append(article) c.condition.notfound = True c.condition.matches = (c.loop.search) return '' |
|
blockconf = IBlockConfig(self.context) self.image_layout = blockconf.image_layout | self.blockconf = IBlockConfig(self.context) self.image_layout = self.blockconf.image_layout | def __init__(self, context, request): super(BlockView, self).__init__(context, request) self.portal_state = getMultiAdapter((self.context, self.request), name=u'plone_portal_state') self.sl_portal_url = self.portal_state.portal_url() blockconf = IBlockConfig(self.context) self.image_layout = blockconf.image_layout |
blockconf = IBlockConfig(self.context) return blockconf.block_height or '' | height = self.blockconf.block_height return height and '%spx' % height or '' | def getBlockHeight(self): blockconf = IBlockConfig(self.context) return blockconf.block_height or '' |
def image_wrapper_style(self): """ sets width of the div wrapping the image, so the caption linebreaks """ blockconf = IBlockConfig(self.context) width, height = blockconf.image_dimension return "width: %spx" % width | def getImageTag(self): alt = unicode(self.context.getImageAltText(), self.context.getCharset()) title = unicode(self.context.getImageCaption(), self.context.getCharset()) |
|
parser.add_option('--value', dest='template_values', action = 'append', | parser.add_option('--value', dest='template_values', action = 'append',default = [], | def main(args): parser = OptionParser("usage: %prog [-o file] [-i file] [--value name1=value --value name2=value ...] template") parser.add_option('--search-path-template', dest='template_search_path', default='.', action = 'store', help = 'Comma seperated list of directories to search for templates (defaults to ".")') parser.add_option('-o', '--out-file', dest='output_file', default = '', action = 'store', help = 'Path to write rendered template to. Defaults to stdout') parser.add_option('-i', '--in-file', dest='input_file', default = '', action = 'store', help = 'Path to file containing JSON encoded values to populate the template. Specify \'-\' to use stdin') parser.add_option('--value', dest='template_values', action = 'append', help = 'name=value pair to be populated in the template. This option may be specified more than once') options, args = parser.parse_args(args) if 2 != len(args): parser.print_usage() return 1 else: template_spec = args[1] tr = TemplateRenderer() if options.output_file: outfile = open(options.output_file, 'w') else: outfile = sys.stdout if options.input_file: if '-' == options.input_file: infile = sys.stdin else: infile = open(options.input_file, 'r') else: infile = None try: template = tr.make_template(template_spec) except ValueError as e: sys.stderr.write(str(e) + '\n') return 1 if infile: tr.add_values(infile) for item in options.template_values: name, value = item.split('=',1) tr.add_value(name,value) tr.render(template, outfile) return 0 |
creator=request.user, name=name, description=description, is_active=True) | creator=request.user, name=name, category=category, description=description, is_active=True) | def create_project(request): if request.method != 'POST': new_project_form = ProjectForm() project_datasets = ProjectDataSetFormSet(prefix='project_datasets') else: project_datasets = ProjectDataSetFormSet(request.POST, prefix='project_datasets') new_project_form = ProjectForm(request.POST) if new_project_form.is_valid() and project_datasets.is_valid(): name = new_project_form.cleaned_data['name'] category = new_project_form.cleaned_data['category'] description = new_project_form.cleaned_data['description'] new_project = Project.objects.create( creator=request.user, name=name, description=description, is_active=True) for dataset_form in project_datasets.forms: if dataset_form.is_valid() and 'dataset' in dataset_form.cleaned_data: dataset = dataset_form.cleaned_data['dataset'] new_project.datasets.add(dataset) view_project_url = get_item_url(new_project, 'epic.projects.views.view_project') return HttpResponseRedirect(view_project_url) return render_to_response( 'projects/create_project.html', {'new_project_form': new_project_form, 'project_datasets': project_datasets}, context_instance=RequestContext(request)) |
if self.generator_module_name == 'initial_data': if os.path.exists('initial_data.json'): os.rename('initial_data.json', 'initial_data.json.bak') print "renaming initial_data.json" else: from django.core import management management.call_command('reset', 'auth', 'sites', 'contenttypes', interactive=False) | def execute(self): # We need a temporary database to store the data created within the # fixture generators. If we don't setup the temporary database, our # actual production database will most likely be dirtied. if self.generator_module_name == 'initial_data': if os.path.exists('initial_data.json'): os.rename('initial_data.json', 'initial_data.json.bak') print "renaming initial_data.json" else: #basically, we're making certain initial_data has all the stuff syncdb includes by default, but none of the other fixtures do, as they'll all effectively 'include' initial_data from django.core import management management.call_command('reset', 'auth', 'sites', 'contenttypes', interactive=False) original_database_name = _setup_temporary_database() self._try_to_generate_fixture() _destroy_temporary_database_and_restore_original( original_database_name) |
|
management.call_command(DJANGO_DUMP_DATA_INTO_FIXTURE_COMMAND) | management.call_command(DJANGO_DUMP_DATA_INTO_FIXTURE_COMMAND, exclude=["contenttypes"]) | def _try_to_generate_fixture(self): # The generator file name is relative to its path. Since we're # not executing from that path, we need the full file path to it. generator_file_name = self._get_full_generator_file_name() fixture_name = self._construct_fixture_file_name() print 'Using fixture generator "%s" to generate fixture "%s".' % \ (self.generator_module_name, fixture_name) self._run_file_as_python_module(generator_file_name) from django.core import management # Create the fixture file to write to. # note: we'll lose the previous fixture if there's an error generating it anew. We really should back it up fixture_file = open(fixture_name, 'w') # Redirect stdout to the fixture file. # TODO: Check for exceptions here |
nodesbytotalawardmoney.sort(bytotalawardmoney) nodesbytotalawardmoney.reverse() for i in range(0, 50): nodesbytotalawardmoney[i].labelvisible=true for i in range(0, 10): print str(nodesbytotalawardmoney[i].label) + ": " + str(nodesbytotalawardmoney[i].totalawardmoney) | nodesByTotalAwardMoney.sort(bytotalawardmoney) nodesByTotalAwardMoney.reverse() for i in range(0, min(nodesByTotalAwardMoney.size(), 50)): nodesByTotalAwardMoney[i].labelvisible=true for i in range(0, min(nodesByTotalAwardMoney, 10)): print str(nodesByTotalAwardMoney[i].label) + ": " + str(nodesByTotalAwardMoney[i].totalawardmoney) | def bytotalawardmoney(n1,n2): return cmp(n1.totalawardmoney, n2.totalawardmoney) |
addNodeField(ORIGINAL_LABEL_FIELD_NAME, Types.VARCHAR, "") setattr(g.nodes, ORIGINAL_LABEL_FIELD_NAME, g.nodes.label) addEdgeField(ORIGINAL_LABEL_FIELD_NAME, Types.VARCHAR, "") setattr(g.edges, ORIGINAL_LABEL_FIELD_NAME, g.edges.label) | def initializeGlobalVariables(): # put all the color names into an array for i in colorInfo: colorList.append(i[0]) gStuff = globals() # all variables that have been declared # the properties of nodes and edges specified in the gdf file originalGraphProperties = [] wantedDefaultProperties = [] # get all methods and variables #MAXIMUM HACKITUDE TO FIX DESPERATE BUG addNodeField(ORIGINAL_LABEL_FIELD_NAME, Types.VARCHAR, "") setattr(g.nodes, ORIGINAL_LABEL_FIELD_NAME, g.nodes.label) addEdgeField(ORIGINAL_LABEL_FIELD_NAME, Types.VARCHAR, "") setattr(g.edges, ORIGINAL_LABEL_FIELD_NAME, g.edges.label) for i in globalDir: if gStuff.has_key(i) and not i == "Edge" and not i == "Node" and not i in colorList: # check to see if it is a variable if str(gStuff[i]) == i: if i in doNotIncludeProperties: #ignore it foo = 2 elif i in defaultProperties: wantedDefaultProperties.append(i) else: originalGraphProperties.append(i) #makes it so original graph properties appear first wantedProperties = originalGraphProperties + wantedDefaultProperties # check to see which properties belong to what for i in wantedProperties: # check to see if it's a node property try: property = "g.nodes[0]." + i eval(property) # will throw an error if it is not a property of a node # find out what type of variable it is nodeProperties[i] = type(eval(property)) nodePropertiesList.append(i) # add to the list of node properties nodePropertyValues[i] = [] # store all the values of that property # find all the values for that node property if it is a string if nodeProperties[i] == type("string"): allvalues = eval("g.nodes."+ i) alluniquevalues = unique(allvalues) nodePropertyValues[i] = alluniquevalues # else find the range if the property is a flot or an integer elif nodeProperties[i] == type(1) or nodeProperties[i] == type(1.5): all_values = eval("g.nodes." + i) if len(all_values) > 0: smallest = min(all_values) largest = max(all_values) else: smallest = 0 largest = 0 nodePropertyValues[i].append(smallest) nodePropertyValues[i].append(largest) # there is an attribute error => i is not a property of a node except AttributeError: # check to see if it is an edge property try: property = "g.edges[0]." + i eval(property) # will throw an error if it is not a property of an edge edgeProperties[i] = type(eval(property)) edgePropertiesList.append(i) edgePropertyValues[i] = [] # find all the values for that edge property if property is a string if edgeProperties[i] == type("string"): allvalues = eval("g.edges."+ i) alluniquevalues = unique(allvalues) edgePropertyValues[i] = alluniquevalues # find the range of values for an edge if it is an integer or float elif edgeProperties[i] == type(1) or edgeProperties[i] == type(1.5): all_values = eval("g.edges." + i) if len(all_values) > 0: smallest = min(all_values) largest = max(all_values) else: smallest = 0 largest = 0 edgePropertyValues[i].append(smallest) edgePropertyValues[i].append(largest) # there is an attribute error => i is not a property of an edge except AttributeError: print i + " is not a property of a node or an edge" # sort the node list counter = 0 for i in g.nodes: nodeIndex.append((i.getName(), counter)) counter = counter + 1 nodeIndex.sort() # sort the edge list counter = 0 for i in g.edges: edgeIndex.append((i.node1.getName() + " - " + i.node2.getName(), counter)) counter = counter + 1 edgeIndex.sort() # Setting the default color of edges & nodes to black. g.edges.labelColor = '0, 0, 0, 255' g.nodes.labelColor = '0, 0, 0, 255' |
|
return HttpResponseredirect(reverse(DEACTIVATED_ACCOUNT_VIEW)) | return HttpResponseRedirect(reverse(DEACTIVATED_ACCOUNT_VIEW)) | def forgot_password(request): if request.method != 'POST': form = ForgotPasswordForm() else: form = ForgotPasswordForm(request.POST) if form.is_valid(): user = form.cleaned_data['user'] if not user.is_active: return HttpResponseredirect(reverse(DEACTIVATED_ACCOUNT_VIEW)) new_password = UserManager().make_random_password() user.set_password(new_password) user.save() success_message = _email_user_about_password_changed(request, user, new_password) return render_to_response( 'core/forgot_password_done.html', {'success_message': success_message,}, context_instance=RequestContext(request)) return render_to_response( 'core/forgot_password.html', {'form': form,}, context_instance=RequestContext(request)) |
email_body = loader.get_template('core/registration_email.html') | email_body = loader.get_template('core/registration_email.txt') | def form_email_about_registration(request, user, profile): email_body = loader.get_template('core/registration_email.html') activation_url = request.build_absolute_uri( reverse('epic.core.views.activate', kwargs={'activation_key': profile.activation_key})) login_url = request.build_absolute_uri(reverse('django.contrib.auth.views.login')) template_context_data = { 'user': user, 'activation_url': activation_url, 'login_url': login_url } template_context = Context(template_context_data) rendered_email = email_body.render(template_context) return rendered_email |
email_body = loader.get_template('core/password_reset_email.html') | email_body = loader.get_template('core/password_reset_email.txt') | def _form_email_about_password_changed(request, user, new_password): email_body = loader.get_template('core/password_reset_email.html') login_url = request.build_absolute_uri(reverse('django.contrib.auth.views.login')) # TODO: Probably not the best security to be sending a plaintext password. template_context_data = { 'first_name': user.first_name, 'last_name': user.last_name, 'username': user.username, 'password': new_password, 'login_url': login_url, } template_context = Context(template_context_data) rendered_email = email_body.render(template_context) return rendered_email |
'f': '%f', 'd': '%f', | 'f': '%.15f', 'd': '%.15f', | def fmt2printfmt(fmt): """Returns printf-like formatter for given binary data type sepecifier.""" fmttypes = { 'B': '%d', # PT_8BUI 'h': '%d', # PT_16BSI 'H': '%d', # PT_16BUI 'i': '%d', # PT_32BSI 'I': '%d', # PT_32BUI 'f': '%f', # PT_32BF 'd': '%f', # PT_64BF 's': '%s' } return fmttypes.get(fmt, 'f') |
extgeom = "ST_Envelope(ST_SetSRID('POLYGON((%f %f,%f %f,%f %f,%f %f,%f %f))'::geometry, %d))" % \ | extgeom = "ST_Envelope(ST_SetSRID('POLYGON((%.15f %.15f,%.15f %.15f,%.15f %.15f,%.15f %.15f,%.15f %.15f))'::geometry, %d))" % \ | def make_sql_addrastercolumn(options, pixeltypes, nodata, pixelsize, blocksize, extent): assert len(pixeltypes) > 0, "No pixel types given" ts = make_sql_schema_table_names(options.table) pt = make_sql_value_array(pixeltypes) nd = 'null' if nodata is not None and len(nodata) > 0: nd = make_sql_value_array(nodata) odb = 'false' if options.register: odb = 'true' rb = 'false' extgeom = 'null' bs = ( 'null', 'null' ) # Check if regular blocking mode requested if options.block_size is not None: assert pixelsize is not None, "Pixel size is none, but regular blocking requested" assert blocksize is not None, "Block size is none, but regular blocking requested" assert extent is not None, "Extent is none, but regular blocking requested" assert len(pixelsize) == 2, "Invalid pixel size, two values expected" assert len(blocksize) == 2, "Invalid block size, two values expected" assert len(extent) == 4, "Invalid extent, four coordinates expected" assert len(extent[0]) == len(extent[3]) == 2, "Invalid extent, pair of X and Y pair expected" rb = 'true' bs = ( blocksize[0], blocksize[1] ) extgeom = "ST_Envelope(ST_SetSRID('POLYGON((%f %f,%f %f,%f %f,%f %f,%f %f))'::geometry, %d))" % \ (extent[0][0], extent[0][1], extent[1][0], extent[1][1], extent[2][0], extent[2][1], extent[3][0], extent[3][1], extent[0][0], extent[0][1], options.srid) sql = "SELECT AddRasterColumn('%s','%s','%s',%d, %s, %s, %s, %s, %f, %f, %s, %s, %s);\n" % \ (ts[0], ts[1], options.column, options.srid, pt, odb, rb, nd, pixelsize[0], pixelsize[1], bs[0], bs[1], extgeom) logit("SQL: %s" % sql) return sql |
sql = "SELECT AddRasterColumn('%s','%s','%s',%d, %s, %s, %s, %s, %f, %f, %s, %s, %s);\n" % \ | sql = "SELECT AddRasterColumn('%s','%s','%s',%d, %s, %s, %s, %s, %.15f, %.15f, %s, %s, %s);\n" % \ | def make_sql_addrastercolumn(options, pixeltypes, nodata, pixelsize, blocksize, extent): assert len(pixeltypes) > 0, "No pixel types given" ts = make_sql_schema_table_names(options.table) pt = make_sql_value_array(pixeltypes) nd = 'null' if nodata is not None and len(nodata) > 0: nd = make_sql_value_array(nodata) odb = 'false' if options.register: odb = 'true' rb = 'false' extgeom = 'null' bs = ( 'null', 'null' ) # Check if regular blocking mode requested if options.block_size is not None: assert pixelsize is not None, "Pixel size is none, but regular blocking requested" assert blocksize is not None, "Block size is none, but regular blocking requested" assert extent is not None, "Extent is none, but regular blocking requested" assert len(pixelsize) == 2, "Invalid pixel size, two values expected" assert len(blocksize) == 2, "Invalid block size, two values expected" assert len(extent) == 4, "Invalid extent, four coordinates expected" assert len(extent[0]) == len(extent[3]) == 2, "Invalid extent, pair of X and Y pair expected" rb = 'true' bs = ( blocksize[0], blocksize[1] ) extgeom = "ST_Envelope(ST_SetSRID('POLYGON((%f %f,%f %f,%f %f,%f %f,%f %f))'::geometry, %d))" % \ (extent[0][0], extent[0][1], extent[1][0], extent[1][1], extent[2][0], extent[2][1], extent[3][0], extent[3][1], extent[0][0], extent[0][1], options.srid) sql = "SELECT AddRasterColumn('%s','%s','%s',%d, %s, %s, %s, %s, %f, %f, %s, %s, %s);\n" % \ (ts[0], ts[1], options.column, options.srid, pt, odb, rb, nd, pixelsize[0], pixelsize[1], bs[0], bs[1], extgeom) logit("SQL: %s" % sql) return sql |
sql = make_sql_insert_raster(gen_table, options.column, hexwkb, options.filename, file) | sql = make_sql_insert_raster(gen_table, options.column, hexwkb, options.filename, infile) | def wkblify_raster_level(options, ds, level, band_range, infile, i): assert ds is not None assert level >= 1 assert len(band_range) == 2 band_from = band_range[0] band_to = band_range[1] # Collect raster and block dimensions raster_size = ( ds.RasterXSize, ds.RasterYSize ) if options.block_size is not None: block_size = parse_block_size(options) read_block_size = ( block_size[0] * level, block_size[1] * level) grid_size = calculate_grid_size(raster_size, read_block_size) else: block_size = raster_size # Whole raster as a single block read_block_size = block_size grid_size = (1, 1) logit("MSG: Processing raster=%s using read_block_size=%s block_size=%s of grid=%s in level=%d\n" % \ (str(raster_size), str(read_block_size), str(block_size), str(grid_size), level)) # Register base raster in RASTER_COLUMNS - SELECT AddRasterColumn(); if level == 1: if i == 0: gt = get_gdal_geotransform(ds) pixel_size = ( gt[1], gt[5] ) pixel_types = collect_pixel_types(ds, band_from, band_to) nodata_values = collect_nodata_values(ds, band_from, band_to) extent = calculate_bounding_box(ds, gt) sql = make_sql_addrastercolumn(options, pixel_types, nodata_values, pixel_size, block_size, extent) options.output.write(sql) gen_table = options.table else: assert level > 1 # Create overview table and register in RASTER_OVERVIEWS # CREATE TABLE o_<LEVEL>_<NAME> ( rid serial, options.column RASTER ) schema_table_names = make_sql_schema_table_names(options.table) level_table_name = 'o_' + str(level) + '_' + schema_table_names[1] level_table = schema_table_names[0] + '.' + level_table_name if i == 0: sql = make_sql_create_table(options, level_table, True) options.output.write(sql) sql = make_sql_register_overview(options, level_table_name, level) options.output.write(sql) gen_table = level_table # Write (original) raster to hex binary output tile_count = 0 hexwkb = '' for ycell in range(0, grid_size[1]): for xcell in range(0, grid_size[0]): xoff = xcell * read_block_size[0] yoff = ycell * read_block_size[1] logit("MSG: --------- CELL #%04d\tindex = %d x %d\tdim = (%d x %d)\t(%d x %d) \t---------\n" % \ (tile_count, xcell, ycell, xoff, yoff, xoff + read_block_size[0], yoff + read_block_size[1])) if options.block_size is not None: hexwkb = '' # Reset buffer as single INSERT per tile is generated hexwkb += wkblify_raster_header(options, ds, level, (xoff, yoff), block_size[0], block_size[1]) else: hexwkb += wkblify_raster_header(options, ds, level, (xoff, yoff)) for b in range(band_from, band_to): band = ds.GetRasterBand(b) assert band is not None, "Missing GDAL raster band %d" % b logit("MSG: Band %d\n" % b) hexwkb += wkblify_band_header(options, band) hexwkb += wkblify_band(options, band, level, xoff, yoff, read_block_size, block_size, infile, b) # INSERT INTO check_hex(hexwkb) # TODO: Remove to not to decrease performance sql = make_sql_insert_raster(gen_table, options.column, hexwkb, options.filename, file) options.output.write(sql) tile_count = tile_count + 1 return (gen_table, tile_count) |
wkblify_raster(opts, filename, i) | wkblify_raster(opts, filename.replace( '\\', '/') , i) | def main(): (opts, args) = parse_command_line() global VERBOSE VERBOSE = opts.verbose global SUMMARY SUMMARY = [] saved_out = sys.stdout if type(opts.output) is str: filename = opts.output opts.output = open(filename, "w") # BEGIN opts.output.write('BEGIN;\n') # If overviews requested, CREATE TABLE raster_overviews if opts.create_raster_overviews_table: sql = make_sql_create_raster_overviews(opts) opts.output.write(sql) # Base raster schema if opts.overview_level == 1: # DROP TABLE if opts.drop_table: sql = make_sql_drop_raster_table(opts.table) opts.output.write(sql) # CREATE TABLE if opts.create_table and opts.overview_level == 1: sql = make_sql_create_table(opts) opts.output.write(sql) # INSERT i = 0 # Burn all specified input raster files into single WKTRaster table for infile in opts.raster: filelist = glob.glob(infile) assert len(filelist) > 0, "No input raster files found for '" + str(infile) + "'" for filename in filelist: logit("MSG: Dataset #%d: %s\n" % (i + 1, filename)) # Write raster data to WKB and send it to opts.output wkblify_raster(opts, filename, i) i += 1 # INDEX if opts.index and SUMMARY is not None: sql = make_sql_create_gist(SUMMARY[0][0], opts.column) opts.output.write(sql) # COMMIT opts.output.write('END;\n') # VACUUM if opts.vacuum and SUMMARY is not None: sql = make_sql_vacuum(SUMMARY[0][0]) opts.output.write(sql) # Cleanup if opts.output != sys.stdout: sys.stdout = saved_out print "------------------------------------------------------------" print " Summary of GDAL to WKT Raster processing:" print "------------------------------------------------------------" if i == 1: m = '%d (%s)' % (i, infile) else: m = '%d' % i print "Number of processed raster files: " + m print "List of generated tables (number of tiles):" i = 0 for s in SUMMARY: i += 1 print "%d\t%s (%d)" % (i, s[0], s[1]) |
def test2(): point_list = [[i] for i in range(1,32)] | def testKdSearchNN(): n = 2**8 point_list = [[i,n-i] for i in range(1,n)] | def test2(): point_list = [[i] for i in range(1,32)] node = kdTree(point_list) node.show() print 'point_list', point_list for point in point_list: best = kdSearchNN(node, point, node, 0) print 'point =', point, ', best =', best.location |
best = kdSearchNN(node, point, node, 0) print 'point =', point, ', best =', best.location | point2 = [x + .4 for x in point] point2 = point best = kdSearchNN(node, point2, node, 0) print 'point =', point, 'point2 =', point2, ', best =', best.location, '***' if point != best.location else '' | def test2(): point_list = [[i] for i in range(1,32)] node = kdTree(point_list) node.show() print 'point_list', point_list for point in point_list: best = kdSearchNN(node, point, node, 0) print 'point =', point, ', best =', best.location |
test2() | testKdSearchNN() | def test2(): point_list = [[i] for i in range(1,32)] node = kdTree(point_list) node.show() print 'point_list', point_list for point in point_list: best = kdSearchNN(node, point, node, 0) print 'point =', point, ', best =', best.location |
showTitle = sys.argv[1].lower().replace(' ', '_') showTitle = sys.argv[1].replace('-', '_') | showTitle = sys.argv[1] showTitle = showTitle.lower() showTitle = showTitle.replace(' ', '_') showTitle = showTitle.replace('-', '_') | def fixupTitle(): showTitle = sys.argv[1].lower().replace(' ', '_') showTitle = sys.argv[1].replace('-', '_') showTitle = showTitle.replace(':', '') showTitle = re.sub('^the_', '', showTitle) showTitle = re.sub('two_and_a_half_men', 'two_half_men', showTitle) return showTitle |
def GlueByContents(fout, url, regmemdate): ur = urllib.urlopen(url) | def GlueByContents(fout, url_contents, regmemdate): ur = urllib.urlopen(url_contents) | def GlueByContents(fout, url, regmemdate): ur = urllib.urlopen(url) sr = ur.read() ur.close() soup = BeautifulSoup.BeautifulSoup(sr) mps = soup.find('a', attrs={'name':'A'}).parent.findNextSiblings('p') for p in mps: ur = urlparse.urljoin(url, p.a['href']) print " reading " + ur ur = urllib.urlopen(ur) sr = ur.read() ur.close() # write the marker telling us which page this comes from lt = time.gmtime() fout.write('<page url="%s" scrapedate="%s" scrapetime="%s"/>\n' % \ (url, time.strftime('%Y-%m-%d', lt), time.strftime('%X', lt))) soup_mp = BeautifulSoup.BeautifulSoup(sr) page = soup_mp.find('h1').findNextSiblings(lambda t: t.name != 'div') page = '\n'.join([ str(p) for p in page ]) + '\n' miscfuncs.WriteCleanText(fout, page) |
ur = urlparse.urljoin(url, p.a['href']) print " reading " + ur ur = urllib.urlopen(ur) | url = urlparse.urljoin(url_contents, p.a['href']) print " reading " + url ur = urllib.urlopen(url) | def GlueByContents(fout, url, regmemdate): ur = urllib.urlopen(url) sr = ur.read() ur.close() soup = BeautifulSoup.BeautifulSoup(sr) mps = soup.find('a', attrs={'name':'A'}).parent.findNextSiblings('p') for p in mps: ur = urlparse.urljoin(url, p.a['href']) print " reading " + ur ur = urllib.urlopen(ur) sr = ur.read() ur.close() # write the marker telling us which page this comes from lt = time.gmtime() fout.write('<page url="%s" scrapedate="%s" scrapetime="%s"/>\n' % \ (url, time.strftime('%Y-%m-%d', lt), time.strftime('%X', lt))) soup_mp = BeautifulSoup.BeautifulSoup(sr) page = soup_mp.find('h1').findNextSiblings(lambda t: t.name != 'div') page = '\n'.join([ str(p) for p in page ]) + '\n' miscfuncs.WriteCleanText(fout, page) |
if re.match('200[6789]', date): | if int(date[0:4]) >= 2006: | def parse_day(self, fp, text, date): self.date = date |
for ixurl in ( 'http://www.publications.parliament.uk/pa/cm/cmregmem/memi02.htm', 'http://www.publications.parliament.uk/pa/cm200304/cmregmem/memi02.htm' ): ur = urllib.urlopen(ixurl) content = ur.read() ur.close(); allurls = re.findall('<a href="([^>]*)">(?i)', content) for url in allurls: if url.find("memi02") >= 0: url = urlparse.urljoin(ixurl, url) ur = urllib.urlopen(url) content = ur.read() ur.close(); content = content.replace(" ", " ") alldates = re.findall('<[Bb]>(\d+ [A-Z][a-z]* \d\d\d\d)', content) if len(alldates) != 1: print alldates raise Exception, 'Date match failed, expected one got %d\n%s' % (len(alldates), url) date = mx.DateTime.DateTimeFrom(alldates[0]).date urls.append((date, url)) | ixurl = 'http://www.publications.parliament.uk/pa/cm/cmregmem/memi02.htm' ur = urllib.urlopen(ixurl) content = ur.read() ur.close(); allurls = re.findall('<a href="([^>]*)">(?i)', content) for url in allurls: if url.find("100203/") >= 0: continue if url.find("memi02") >= 0: url = urlparse.urljoin(ixurl, url) ur = urllib.urlopen(url) content = ur.read() ur.close(); content = content.replace(" ", " ") alldates = re.findall('<[Bb]>(\d+ [A-Z][a-z]* \d\d\d\d)', content) if len(alldates) != 1: print alldates raise Exception, 'Date match failed, expected one got %d\n%s' % (len(alldates), url) date = mx.DateTime.DateTimeFrom(alldates[0]).date urls.append((date, url)) | def FindRegmemPages(): urls = [] # Meta index is here: 'http://www.publications.parliament.uk/pa/cm/cmhocpap.htm' # We just grab some specific session index pages as it is too hard otherwise. # The first URL /pa/cm/cmregmem/memi02.htm should get all new regmems as they # arrive anyway. for ixurl in ( 'http://www.publications.parliament.uk/pa/cm/cmregmem/memi02.htm', 'http://www.publications.parliament.uk/pa/cm200304/cmregmem/memi02.htm' ): # print "IXURL", ixurl ur = urllib.urlopen(ixurl) content = ur.read() ur.close(); # <A HREF="/pa/cm199900/cmregmem/memi02.htm">Register # of Members' Interests November 2000</A> allurls = re.findall('<a href="([^>]*)">(?i)', content) for url in allurls: #print url if url.find("memi02") >= 0: url = urlparse.urljoin(ixurl, url) # find date ur = urllib.urlopen(url) content = ur.read() ur.close(); # <B>14 May 2001 (Dissolution)</B> content = content.replace(" ", " ") alldates = re.findall('<[Bb]>(\d+ [A-Z][a-z]* \d\d\d\d)', content) if len(alldates) != 1: print alldates raise Exception, 'Date match failed, expected one got %d\n%s' % (len(alldates), url) date = mx.DateTime.DateTimeFrom(alldates[0]).date #print date, url urls.append((date, url)) return urls |
if len(args) == 1: buildconfig = _GetConfig(args[0]) | if len(args) >= 1: buildconfig = _GetConfig(args[-1]) | def main(): # Parse options usage = "usage: %prog [options] cbuildbot_config" parser = optparse.OptionParser(usage=usage) parser.add_option('-r', '--buildroot', help='root directory where build occurs', default=".") parser.add_option('-n', '--buildnumber', help='build number', type='int', default=0) parser.add_option('-f', '--revisionfile', help='file where new revisions are stored') parser.add_option('--clobber', action='store_true', dest='clobber', default=False, help='Clobbers an old checkout before syncing') (options, args) = parser.parse_args() buildroot = options.buildroot revisionfile = options.revisionfile # Passed option to clobber. if options.clobber: RunCommand(['sudo', 'rm', '-rf', buildroot]) if len(args) == 1: buildconfig = _GetConfig(args[0]) else: Warning('Missing configuration description') parser.print_usage() sys.exit(1) try: if not os.path.isdir(buildroot): _FullCheckout(buildroot) else: _IncrementalCheckout(buildroot) chroot_path = os.path.join(buildroot, 'chroot') if not os.path.isdir(chroot_path): _MakeChroot(buildroot) boardpath = os.path.join(chroot_path, 'build', buildconfig['board']) if not os.path.isdir(boardpath): _SetupBoard(buildroot, board=buildconfig['board']) if buildconfig['uprev']: _UprevPackages(buildroot, revisionfile, board=buildconfig['board']) _Build(buildroot) if buildconfig['unittests']: _RunUnitTests(buildroot) _BuildImage(buildroot) if buildconfig['uprev']: if buildconfig['master']: # Master bot needs to check if the other slaves completed. if cbuildbot_comm.HaveSlavesCompleted(config): _UprevPush(buildroot) _UprevCleanup(buildroot) else: # At least one of the slaves failed or we timed out. _UprevCleanup(buildroot) Die('CBUILDBOT - One of the slaves has failed!!!') else: # Publish my status to the master if its expecting it. if buildconfig['important']: cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) _UprevCleanup(buildroot) except: # Send failure to master bot. if not buildconfig['master'] and buildconfig['important']: cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) raise |
'client.*.DEBUG') | '%s*.DEBUG' % os.path.basename(test)) | def _GenerateReportText(self): """Prints a result report to stdout. |
if buildconfig['master']: if cbuildbot_comm.HaveSlavesCompleted(config): _UprevPush(buildroot) _UprevCleanup(buildroot) | if options.debug: if buildconfig['master']: if cbuildbot_comm.HaveSlavesCompleted(config): _UprevPush(buildroot) else: _UprevCleanup(buildroot) Die('CBUILDBOT - One of the slaves has failed!!!') | def main(): # Parse options usage = "usage: %prog [options] cbuildbot_config" parser = optparse.OptionParser(usage=usage) parser.add_option('-r', '--buildroot', help='root directory where build occurs', default=".") parser.add_option('-n', '--buildnumber', help='build number', type='int', default=0) parser.add_option('-f', '--revisionfile', help='file where new revisions are stored') parser.add_option('--clobber', action='store_true', dest='clobber', default=False, help='Clobbers an old checkout before syncing') (options, args) = parser.parse_args() buildroot = options.buildroot revisionfile = options.revisionfile # Passed option to clobber. if options.clobber: RunCommand(['sudo', 'rm', '-rf', buildroot]) if len(args) >= 1: buildconfig = _GetConfig(args[-1]) else: Warning('Missing configuration description') parser.print_usage() sys.exit(1) try: if not os.path.isdir(buildroot): _FullCheckout(buildroot) else: _PreFlightRinse(buildroot) _IncrementalCheckout(buildroot) chroot_path = os.path.join(buildroot, 'chroot') if not os.path.isdir(chroot_path): _MakeChroot(buildroot) boardpath = os.path.join(chroot_path, 'build', buildconfig['board']) if not os.path.isdir(boardpath): _SetupBoard(buildroot, board=buildconfig['board']) if buildconfig['uprev']: _UprevPackages(buildroot, revisionfile, board=buildconfig['board']) _EnableLocalAccount(buildroot) _Build(buildroot) if buildconfig['unittests']: _RunUnitTests(buildroot) _BuildImage(buildroot) if buildconfig['smoke_bvt']: _BuildVMImageForTesting(buildroot) _RunSmokeSuite(buildroot) if buildconfig['uprev']: if buildconfig['master']: # Master bot needs to check if the other slaves completed. if cbuildbot_comm.HaveSlavesCompleted(config): _UprevPush(buildroot) _UprevCleanup(buildroot) else: # At least one of the slaves failed or we timed out. _UprevCleanup(buildroot) Die('CBUILDBOT - One of the slaves has failed!!!') else: # Publish my status to the master if its expecting it. if buildconfig['important']: cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) _UprevCleanup(buildroot) except: # Send failure to master bot. if not buildconfig['master'] and buildconfig['important']: cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) raise |
_UprevCleanup(buildroot) Die('CBUILDBOT - One of the slaves has failed!!!') else: if buildconfig['important']: cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) _UprevCleanup(buildroot) | if buildconfig['important']: cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) _UprevCleanup(buildroot) | def main(): # Parse options usage = "usage: %prog [options] cbuildbot_config" parser = optparse.OptionParser(usage=usage) parser.add_option('-r', '--buildroot', help='root directory where build occurs', default=".") parser.add_option('-n', '--buildnumber', help='build number', type='int', default=0) parser.add_option('-f', '--revisionfile', help='file where new revisions are stored') parser.add_option('--clobber', action='store_true', dest='clobber', default=False, help='Clobbers an old checkout before syncing') (options, args) = parser.parse_args() buildroot = options.buildroot revisionfile = options.revisionfile # Passed option to clobber. if options.clobber: RunCommand(['sudo', 'rm', '-rf', buildroot]) if len(args) >= 1: buildconfig = _GetConfig(args[-1]) else: Warning('Missing configuration description') parser.print_usage() sys.exit(1) try: if not os.path.isdir(buildroot): _FullCheckout(buildroot) else: _PreFlightRinse(buildroot) _IncrementalCheckout(buildroot) chroot_path = os.path.join(buildroot, 'chroot') if not os.path.isdir(chroot_path): _MakeChroot(buildroot) boardpath = os.path.join(chroot_path, 'build', buildconfig['board']) if not os.path.isdir(boardpath): _SetupBoard(buildroot, board=buildconfig['board']) if buildconfig['uprev']: _UprevPackages(buildroot, revisionfile, board=buildconfig['board']) _EnableLocalAccount(buildroot) _Build(buildroot) if buildconfig['unittests']: _RunUnitTests(buildroot) _BuildImage(buildroot) if buildconfig['smoke_bvt']: _BuildVMImageForTesting(buildroot) _RunSmokeSuite(buildroot) if buildconfig['uprev']: if buildconfig['master']: # Master bot needs to check if the other slaves completed. if cbuildbot_comm.HaveSlavesCompleted(config): _UprevPush(buildroot) _UprevCleanup(buildroot) else: # At least one of the slaves failed or we timed out. _UprevCleanup(buildroot) Die('CBUILDBOT - One of the slaves has failed!!!') else: # Publish my status to the master if its expecting it. if buildconfig['important']: cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) _UprevCleanup(buildroot) except: # Send failure to master bot. if not buildconfig['master'] and buildconfig['important']: cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) raise |
def FixPostInst(mount_point): postinst_in = os.path.join(mount_point, POST_INST_IN_FILENAME) f = open(postinst_in, 'r') postinst = f.read() f.close() m1 = postinst.find(EFI_CODE_MARKER_START) m2 = postinst.find(EFI_CODE_MARKER_END) if (m1 == -1) or (m2 == -1) or (m1 > m2): return m2 += len(EFI_CODE_MARKER_END) postinst = postinst[0:m1] + postinst[m2:] postinst_out = os.path.join(mount_point, POST_INST_OUT_FILENAME) f = open(postinst_out, 'w') f.write(postinst) f.close() os.chmod(postinst_out, stat.S_IEXEC | stat.S_IREAD) | def FixXorgConf(mount_point): xorg_conf_filename = os.path.join(mount_point, XORG_CONF_FILENAME) f = open(xorg_conf_filename, 'r') xorg_conf = f.read() f.close() more_sections = 1 last_found = 0 while (more_sections): # Find the input section. m1 = xorg_conf.find(INPUT_SECTION_MARKER, last_found) if m1 > -1: m2 = xorg_conf.find(SECTION_END_MARKER, m1) m2 += len(SECTION_END_MARKER) # Make sure the next iteration doesn't rinse/repeat. last_found = m2 # Check if this is a mouse section. for ident in MOUSE_SECTION_IDENTIFIERS: if xorg_conf.find(ident, m1, m2) != -1: xorg_conf = xorg_conf[0:m1] + xorg_conf[m2:] last_found -= (m2-m1) break else: more_sections = 0 xorg_conf = xorg_conf[0:last_found] + TABLET_DEVICE_CONFIG + \ xorg_conf[last_found:] # Replace UsbMouse with Tablet. xorg_conf = xorg_conf.replace(REPLACE_USB_MOUSE_PAIR[0], REPLACE_USB_MOUSE_PAIR[1]) # Write the file back out. f = open(xorg_conf_filename, 'w') f.write(xorg_conf) f.close() |
|
parser.add_option('--for_qemu', dest='for_qemu', | parser.add_option('--enable_tablet', dest='enable_tablet', | def main(): parser = OptionParser(USAGE) parser.add_option('--mounted_dir', dest='mounted_dir', help='directory where the Chromium OS image is mounted') parser.add_option('--for_qemu', dest='for_qemu', default="true", help='fixup image for qemu') (options, args) = parser.parse_args() if not options.mounted_dir: parser.error("Please specify the mount point for the Chromium OS image"); if options.for_qemu not in ('true', 'false'): parser.error("Please specify either true or false for --for_qemu") FixPostInst(options.mounted_dir) if (options.for_qemu == 'true'): FixXorgConf(options.mounted_dir) |
if options.for_qemu not in ('true', 'false'): parser.error("Please specify either true or false for --for_qemu") | if options.enable_tablet not in ('true', 'false'): parser.error("Please specify either true or false for --enable_tablet") | def main(): parser = OptionParser(USAGE) parser.add_option('--mounted_dir', dest='mounted_dir', help='directory where the Chromium OS image is mounted') parser.add_option('--for_qemu', dest='for_qemu', default="true", help='fixup image for qemu') (options, args) = parser.parse_args() if not options.mounted_dir: parser.error("Please specify the mount point for the Chromium OS image"); if options.for_qemu not in ('true', 'false'): parser.error("Please specify either true or false for --for_qemu") FixPostInst(options.mounted_dir) if (options.for_qemu == 'true'): FixXorgConf(options.mounted_dir) |
FixPostInst(options.mounted_dir) if (options.for_qemu == 'true'): | if (options.enable_tablet == 'true'): | def main(): parser = OptionParser(USAGE) parser.add_option('--mounted_dir', dest='mounted_dir', help='directory where the Chromium OS image is mounted') parser.add_option('--for_qemu', dest='for_qemu', default="true", help='fixup image for qemu') (options, args) = parser.parse_args() if not options.mounted_dir: parser.error("Please specify the mount point for the Chromium OS image"); if options.for_qemu not in ('true', 'false'): parser.error("Please specify either true or false for --for_qemu") FixPostInst(options.mounted_dir) if (options.for_qemu == 'true'): FixXorgConf(options.mounted_dir) |
if (revision_file): | if (revisionfile): | def _UprevPackages(buildroot, revisionfile): revisions = None if (revision_file): rev_file = revisionfile.open(revisionfile) revisions = rev_file.read() rev_file.close() # Note: Revisions == "None" indicates a Force Build. if revisions and revisions != 'None': print 'CBUILDBOT - Revision list found %s' % revisions print 'Revision list not yet propagating to build, marking all instead' _UprevAllPackages(buildroot) |
def RevGitFile(filename, key, value): """Update and push the git file. | def setUp(self): self.mox = mox.Mox() | def RevGitFile(filename, key, value): """Update and push the git file. Args: filename: file to modify that is in a git repo already key: board or host package type e.g. x86-dogfood value: string representing the version of the prebuilt that has been uploaded. """ prebuilt_branch = 'prebuilt_branch' old_cwd = os.getcwd() os.chdir(os.path.dirname(filename)) cros_build_lib.RunCommand('repo start %s .' % prebuilt_branch, shell=True) UpdateLocalFile(filename, key, value) description = 'Update BINHOST key/value %s %s' % (key, value) print description git_ssh_config_cmd = ('git config ' 'url.ssh://git@gitrw.chromium.org:9222.pushinsteadof ' 'http://git.chromium.org/git') try: cros_build_lib.RunCommand(git_ssh_config_cmd, shell=True) cros_build_lib.RunCommand('git config push.default tracking', shell=True) cros_build_lib.RunCommand('git commit -am "%s"' % description, shell=True) cros_build_lib.RunCommand('git push', shell=True) finally: cros_build_lib.RunCommand('repo abandon %s .' % prebuilt_branch, shell=True) os.chdir(old_cwd) |
Args: filename: file to modify that is in a git repo already key: board or host package type e.g. x86-dogfood value: string representing the version of the prebuilt that has been uploaded. """ prebuilt_branch = 'prebuilt_branch' old_cwd = os.getcwd() os.chdir(os.path.dirname(filename)) cros_build_lib.RunCommand('repo start %s .' % prebuilt_branch, shell=True) UpdateLocalFile(filename, key, value) description = 'Update BINHOST key/value %s %s' % (key, value) print description git_ssh_config_cmd = ('git config ' 'url.ssh://git@gitrw.chromium.org:9222.pushinsteadof ' 'http://git.chromium.org/git') try: cros_build_lib.RunCommand(git_ssh_config_cmd, shell=True) cros_build_lib.RunCommand('git config push.default tracking', shell=True) cros_build_lib.RunCommand('git commit -am "%s"' % description, shell=True) cros_build_lib.RunCommand('git push', shell=True) finally: cros_build_lib.RunCommand('repo abandon %s .' % prebuilt_branch, shell=True) os.chdir(old_cwd) | def tearDown(self): self.mox.UnsetStubs() self.mox.VerifyAll() | def RevGitFile(filename, key, value): """Update and push the git file. Args: filename: file to modify that is in a git repo already key: board or host package type e.g. x86-dogfood value: string representing the version of the prebuilt that has been uploaded. """ prebuilt_branch = 'prebuilt_branch' old_cwd = os.getcwd() os.chdir(os.path.dirname(filename)) cros_build_lib.RunCommand('repo start %s .' % prebuilt_branch, shell=True) UpdateLocalFile(filename, key, value) description = 'Update BINHOST key/value %s %s' % (key, value) print description git_ssh_config_cmd = ('git config ' 'url.ssh://git@gitrw.chromium.org:9222.pushinsteadof ' 'http://git.chromium.org/git') try: cros_build_lib.RunCommand(git_ssh_config_cmd, shell=True) cros_build_lib.RunCommand('git config push.default tracking', shell=True) cros_build_lib.RunCommand('git commit -am "%s"' % description, shell=True) cros_build_lib.RunCommand('git push', shell=True) finally: cros_build_lib.RunCommand('repo abandon %s .' % prebuilt_branch, shell=True) os.chdir(old_cwd) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.