rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
]),
]) data_files = [
def get_data_files(): data_files=[ (r'Microsoft.VC90.CRT', [ r'lib\Microsoft.VC90.CRT\Microsoft.VC90.CRT.manifest', r'lib\Microsoft.VC90.CRT\msvcr90.dll', ]), (r'', [r'lib\avbin.dll']), ] data_files += all_files(r'data') return data_files
TIP_SPEED = 10
if self.dy < 0: tip_speed = 10 else: tip_speed = 20
def sprite_rotation(self): # below half this speed, bird rotation is zero # above half this speed, bird rotates towards direction of motion # above this speed, bird rotation == direction of motion TIP_SPEED = 10
if speed < TIP_SPEED / 2:
if speed < tip_speed / 2:
def sprite_rotation(self): # below half this speed, bird rotation is zero # above half this speed, bird rotates towards direction of motion # above this speed, bird rotation == direction of motion TIP_SPEED = 10
if speed < TIP_SPEED:
if speed < tip_speed:
def sprite_rotation(self): # below half this speed, bird rotation is zero # above half this speed, bird rotates towards direction of motion # above this speed, bird rotation == direction of motion TIP_SPEED = 10
ratio = speed * 2 / TIP_SPEED - 1
ratio = speed * 2 / tip_speed - 1
def sprite_rotation(self): # below half this speed, bird rotation is zero # above half this speed, bird rotates towards direction of motion # above this speed, bird rotation == direction of motion TIP_SPEED = 10
def __init__(self, char, type = "strict"):
def __init__(self, char, regexp_type = "strict"):
def __init__(self, char, type = "strict"): from sre_parse import DIGITS, SPECIAL_CHARS, CATEGORY_DIGIT from sre_parse import WHITESPACE, CATEGORY_SPACE def _getCategory(char): if (None == char): return Char.NONE elif ('_' == char): return Char.OTHER_WORD elif (char in DIGITS): return CATEGORY_DIGIT elif (char in SPECIA...
self._type = type
self._regexp_type = regexp_type
def _getCategory(char): if (None == char): return Char.NONE elif ('_' == char): return Char.OTHER_WORD elif (char in DIGITS): return CATEGORY_DIGIT elif (char in SPECIAL_CHARS): return Char.SPECIAL elif (char in WHITESPACE): return CATEGORY_SPACE elif (char.isalpha()): if (char.islower()): return Char.LOWER_CASE_LETTER...
def getString(self, type = "strict"):
def getString(self, regexp_type = "strict"):
def getString(self, type = "strict"): """String representation of a sequence used to generate the regular expression.""" return ""
def getString(self, type = "strict"): """The result depends on `type`. If `type` is "strict" the representation will be the exact interval (@TODO ? except if the whole class is covered for \d and \s). If `type` is "lax" the representation of the class will be used for some characters : - digit -> \d - letter or '_' -> ...
def getString(self, regexp_type = "strict"): """The result depends on `regexp_type`. If `regexp_type` is "strict" the representation will be the exact interval(@TODO ? except if the whole class is covered for \d and \s). If `regexp_type` is "lax" the representation of the class will be used for some characters : - digi...
def getString(self, type = "strict"): """The result depends on `type`. If `type` is "strict" the representation will be the exact interval (@TODO ? except if the whole class is covered for \d and \s). If `type` is "lax" the representation of the class will be used for some characters : - digit -> \d - letter or '_' -> ...
if (("lax" == type) and (self._max != self._min) and
if (("lax" == regexp_type) and (self._max != self._min) and
def getString(self, type = "strict"): """The result depends on `type`. If `type` is "strict" the representation will be the exact interval (@TODO ? except if the whole class is covered for \d and \s). If `type` is "lax" the representation of the class will be used for some characters : - digit -> \d - letter or '_' -> ...
def getString(self, type = "strict"):
def getString(self, regexp_type = "strict"):
def getString(self, type = "strict"): """This has only been implemented with OR kind in mind. The result depends on `type`. If `type` is "strict" the representation will be the exact interval (@TODO ? except if the whole class is covered for \d and \s). If `type` is "lax" the representation of the class will be used fo...
The result depends on `type`. If `type` is "strict" the representation will be the exact interval (@TODO ? except if the whole class is covered for \d and \s). If `type` is "lax" the representation of the class will be used for some characters :
The result depends on `regexp_type`. If `regexp_type` is "strict" the representation will be the exact interval(@TODO ? except if the whole class is covered for \d and \s). If `regexp_type` is "lax" the representation of the class will be used for some characters :
def getString(self, type = "strict"): """This has only been implemented with OR kind in mind. The result depends on `type`. If `type` is "strict" the representation will be the exact interval (@TODO ? except if the whole class is covered for \d and \s). If `type` is "lax" the representation of the class will be used fo...
("lax" == type)):
("lax" == regexp_type)):
def getString(self, type = "strict"): """This has only been implemented with OR kind in mind. The result depends on `type`. If `type` is "strict" the representation will be the exact interval (@TODO ? except if the whole class is covered for \d and \s). If `type` is "lax" the representation of the class will be used fo...
digits += sequence.getString(type)
digits += sequence.getString(regexp_type)
def getString(self, type = "strict"): """This has only been implemented with OR kind in mind. The result depends on `type`. If `type` is "strict" the representation will be the exact interval (@TODO ? except if the whole class is covered for \d and \s). If `type` is "lax" the representation of the class will be used fo...
words += sequence.getString(type)
words += sequence.getString(regexp_type)
def getString(self, type = "strict"): """This has only been implemented with OR kind in mind. The result depends on `type`. If `type` is "strict" the representation will be the exact interval (@TODO ? except if the whole class is covered for \d and \s). If `type` is "lax" the representation of the class will be used fo...
spaces += sequence.getString(type)
spaces += sequence.getString(regexp_type)
def getString(self, type = "strict"): """This has only been implemented with OR kind in mind. The result depends on `type`. If `type` is "strict" the representation will be the exact interval (@TODO ? except if the whole class is covered for \d and \s). If `type` is "lax" the representation of the class will be used fo...
others += sequence.getString(type)
others += sequence.getString(regexp_type)
def getString(self, type = "strict"): """This has only been implemented with OR kind in mind. The result depends on `type`. If `type` is "strict" the representation will be the exact interval (@TODO ? except if the whole class is covered for \d and \s). If `type` is "lax" the representation of the class will be used fo...
if (("lax" == type) and (add_digits_class)):
if (("lax" == regexp_type) and (add_digits_class)):
def getString(self, type = "strict"): """This has only been implemented with OR kind in mind. The result depends on `type`. If `type` is "strict" the representation will be the exact interval (@TODO ? except if the whole class is covered for \d and \s). If `type` is "lax" the representation of the class will be used fo...
if (("lax" == type) and (add_words_class)):
if (("lax" == regexp_type) and (add_words_class)):
def getString(self, type = "strict"): """This has only been implemented with OR kind in mind. The result depends on `type`. If `type` is "strict" the representation will be the exact interval (@TODO ? except if the whole class is covered for \d and \s). If `type` is "lax" the representation of the class will be used fo...
if (("lax" == type) and (add_spaces_class)):
if (("lax" == regexp_type) and (add_spaces_class)):
def getString(self, type = "strict"): """This has only been implemented with OR kind in mind. The result depends on `type`. If `type` is "strict" the representation will be the exact interval (@TODO ? except if the whole class is covered for \d and \s). If `type` is "lax" the representation of the class will be used fo...
def __init__(self, type = "strict"): logging.debug("Created an object of type '%s'", "SequenceFactory") self._type = type
def __init__(self, regexp_type = "strict"): logging.debug("Created an object of regexp_type '%s'", "SequenceFactory") self._regexp_type = regexp_type
def __init__(self, type = "strict"): logging.debug("Created an object of type '%s'", "SequenceFactory") self._type = type
return Sequence(Char(char, self._type))
return Sequence(Char(char, self._regexp_type))
def createSequence(self, char): """Creates a sequence containing the character `char`.""" return Sequence(Char(char, self._type))
def __init__(self, characters, iType):
def __init__(self, characters, regexp_type):
def __init__(self, characters, iType): """characters : the characters the node will have to match. iType : ("strict" | "lax")""" self._len = len(characters) self._range = characters characters = list(set(characters)) characters.sort() if ((len(self._range) > 1) and (len(characters) == 1)): iType = "strict" logging.debu...
iType : ("strict" | "lax")"""
regexp_type : ("strict" | "lax")"""
def __init__(self, characters, iType): """characters : the characters the node will have to match. iType : ("strict" | "lax")""" self._len = len(characters) self._range = characters characters = list(set(characters)) characters.sort() if ((len(self._range) > 1) and (len(characters) == 1)): iType = "strict" logging.debu...
iType = "strict"
regexp_type = "strict"
def __init__(self, characters, iType): """characters : the characters the node will have to match. iType : ("strict" | "lax")""" self._len = len(characters) self._range = characters characters = list(set(characters)) characters.sort() if ((len(self._range) > 1) and (len(characters) == 1)): iType = "strict" logging.debu...
def getString(self, type = "strict"):
def getString(self, regexp_type = "strict"):
def getString(self, type = "strict"): """Returns the mini regular expression coding for this character without considering the possibility that it is optional.""" return self._root_sequence.getString(type)
return self._root_sequence.getString(type) def generate(sample_strings, iType = "lax"):
return self._root_sequence.getString(regexp_type) def generate(sample_strings, regexp_type = "lax"):
def getString(self, type = "strict"): """Returns the mini regular expression coding for this character without considering the possibility that it is optional.""" return self._root_sequence.getString(type)
logging.debug("node.getString(iType) = %s", node.getString(iType))
logging.debug("node.getString(regexp_type) = %s", node.getString(regexp_type))
def generate(sample_strings, iType = "lax"): """`sample_strings`: list of strings for which to generate a matching regexp. It does not need to be ordered. Returns a regular expression that matches the sample strings. The regular expression is checked against the strings at the end. An error is logged if the regular exp...
if (ref_node.getString(iType) == node.getString(iType)):
if (ref_node.getString(regexp_type) == node.getString(regexp_type)):
def generate(sample_strings, iType = "lax"): """`sample_strings`: list of strings for which to generate a matching regexp. It does not need to be ordered. Returns a regular expression that matches the sample strings. The regular expression is checked against the strings at the end. An error is logged if the regular exp...
result += ref_node.getString(iType)
result += ref_node.getString(regexp_type)
def generate(sample_strings, iType = "lax"): """`sample_strings`: list of strings for which to generate a matching regexp. It does not need to be ordered. Returns a regular expression that matches the sample strings. The regular expression is checked against the strings at the end. An error is logged if the regular exp...
logging.debug("ref_node.getString(iType) = %s", ref_node.getString(iType))
logging.debug("ref_node.getString(regexp_type) = %s", ref_node.getString(regexp_type))
def generate(sample_strings, iType = "lax"): """`sample_strings`: list of strings for which to generate a matching regexp. It does not need to be ordered. Returns a regular expression that matches the sample strings. The regular expression is checked against the strings at the end. An error is logged if the regular exp...
def test_generate(data, type, expected = None):
def test_generate(data, regexp_type, expected = None):
def test_generate(data, type, expected = None): """`data`: list of strings used to generate the regular expression. `type`: "strict" | "lax" `expected`: if provided, string containing the expected regular expression. """ exp = generate(data, type) logging.info(str(data) + " -> " + exp) if (None != expected): checkEqua...
`type`: "strict" | "lax"
`regexp_type`: "strict" | "lax"
def test_generate(data, type, expected = None): """`data`: list of strings used to generate the regular expression. `type`: "strict" | "lax" `expected`: if provided, string containing the expected regular expression. """ exp = generate(data, type) logging.info(str(data) + " -> " + exp) if (None != expected): checkEqua...
exp = generate(data, type)
exp = generate(data, regexp_type)
def test_generate(data, type, expected = None): """`data`: list of strings used to generate the regular expression. `type`: "strict" | "lax" `expected`: if provided, string containing the expected regular expression. """ exp = generate(data, type) logging.info(str(data) + " -> " + exp) if (None != expected): checkEqua...
self._indexes = {}
self._indexes = []
def __init__(self, cursor, model, module_name=None, history=False): super(TableHandler, self).__init__(cursor, model, module_name=module_name, history=history) self._columns = {} self._constraints = [] self._fk_deltypes = {} self._indexes = {} self._field2module = {}
obj = self.pool.get(self._columns[field].model_name)
obj = self.pool.get(fld_def.model_name)
fld_def = (field in self._columns) and self._columns[field] \ or self._inherit_fields[field][2]
pipe = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True, env=child_env)
pipe = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=child_env)
def exec_pg_command_pipe(name, *args): prog = find_pg_tool(name) if not prog: raise Exception('Couldn\'t find %s' % name) if os.name == "nt": cmd = '"' + prog + '" ' + ' '.join(args) else: cmd = prog + ' ' + ' '.join(args) # if db_password is set in configuration we should pass # an environment variable PGPASSWORD to ...
return int(user)
return int(Transaction().user)
def default_act_from(self): return int(user)
return int(user)
return int(Transaction().user)
def default_act_to(self): return int(user)
'float': 0.1234567890123456789,
'float': 0.123456789012345,
def test0030float(self): ''' Test Float. ''' cursor = DB.cursor()
self.assert_(float7['float'] == 0.1234567890123456789)
self.assert_(float7['float'] == 0.123456789012345)
def test0030float(self): ''' Test Float. ''' cursor = DB.cursor()
res.append(res2)
res.extend(res2)
def process_liness(self, datas, prefix, fields_def, position=0): line = datas[position] row = {} translate = {} todo = [] warning = ''
return [record.get_eval() for record in self]
return [record.id for record in self]
def get_eval(self): return [record.get_eval() for record in self]
tb_s += error.message.decode('utf-8', 'ignore')
tb_s += str(error).decode('utf-8', 'ignore')
def _callback(self, cron): try: args = (cron['args'] or []) and safe_eval(cron['args']) obj = self.pool.get(cron['model']) if not obj and hasattr(obj, cron['function']): return False fct = getattr(obj, cron['function']) fct(cron['user'], *args) except Exception, error: Transaction().cursor.rollback()
('fs_is', '=', fs_id),
('fs_id', '=', fs_id),
def get_id(self, cursor, user, module, fs_id): """ Return for an fs_id the corresponding db_id.
help='enable debug mode')
help='enable debug mode (start post-mortem debugger if exceptions occur)')
def parse(self): parser = optparse.OptionParser(version=VERSION)
self.assert_(TRIGGER_LOGS == [([triggered_id], triggered_id)])
self.assert_(TRIGGER_LOGS == [([triggered_id], trigger_id)])
def test0040on_delete(self): ''' Test on_delete ''' cursor = DB.cursor()
field.context_validate(value)
fields.context_validate(value)
def check_context(self, cursor, user, ids): "Check context" for action in self.browse(cursor, user, ids): if action.context: try: value = safe_eval(action.context, CONTEXT) except: return False if isinstance(value, PYSON): if not value.types() == set([dict]): return False elif not isinstance(value, dict): return False ...
if value.time() != datetime.time(): assert(not isinstance(value, datetime.datetime))
assert(not isinstance(value, datetime.datetime) or value.time() == datetime.time())
def sql_format(value): if not value: return None if isinstance(value, basestring): year, month, day = map(int, value.split("-", 2)) return datetime.date(year, month, day)
if isinstance(domain[i][2], basestring): res_ids = target_obj.search(cursor, user, [ ('rec_name', domain[i][1], domain[i][2]), ], order=[], context=context) elif isinstance(domain[i][2], (int, long)) \ and not isinstance(domain[i][2], bool): res_ids = [domain[i][2]] else: res_ids = domain[i][2] if res_ids == True or re...
if isinstance(domain[i][2], bool):
def _rec_get(ids, table, parent): if not ids: return [] ids2 = table.search(cursor, user, [(parent, 'in', ids), (parent, '!=', False)], order=[], context=context) return ids + _rec_get(ids2, table, parent)
if res_ids == False:
if domain[i][2] == False:
def _rec_get(ids, table, parent): if not ids: return [] ids2 = table.search(cursor, user, [(parent, 'in', ids), (parent, '!=', False)], order=[], context=context) return ids + _rec_get(ids2, table, parent)
elif not res_ids: domain[i] = ('id', '=', '0')
def _rec_get(ids, table, parent): if not ids: return [] ids2 = table.search(cursor, user, [(parent, 'in', ids), (parent, '!=', False)], order=[], context=context) return ids + _rec_get(ids2, table, parent)
red_sql, red_ids = reduce_ids('"' + field.target + '"', res_ids) query1 = 'SELECT "' + field.origin + '" ' \ 'FROM "' + relation_obj._table + '" ' \ 'WHERE ' + red_sql query2 = red_ids
query1, query2 = target_obj.search([ (target_field, domain[i][1], domain[i][2]), ], order=[], query_string=True) query1 = ('SELECT "%s" FROM "%s" WHERE "%s" IN (%s)' % (field.origin, relation_obj._table, field.target, query1))
def _rec_get(ids, table, parent): if not ids: return [] ids2 = table.search(cursor, user, [(parent, 'in', ids), (parent, '!=', False)], order=[], context=context) return ids + _rec_get(ids2, table, parent)
if not history_table.column_exist(column_name): history_table.add_raw_column(column_name, (table._columns[column_name]['typname'], table._columns[column_name]['typname']), None, string=table._columns[column_name].string)
string = '' if column_name in self._columns: string = self._columns[column_name].string history_table.add_raw_column(column_name, (table._columns[column_name]['typname'], table._columns[column_name]['typname']), None, string=string)
def _update_history_table(self, cursor): if self._history: table = TableHandler(cursor, self) history_table = TableHandler(cursor, self, history=True) for column_name in table._columns: if not history_table.column_exist(column_name): history_table.add_raw_column(column_name, (table._columns[column_name]['typname'], tab...
if isinstance(domain[i][2], basestring): res_ids = target_obj.search([ ('rec_name', domain[i][1], domain[i][2]), ], order=[]) elif isinstance(domain[i][2], (int, long)) \ and not isinstance(domain[i][2], bool): res_ids = [domain[i][2]] else: res_ids = domain[i][2] if res_ids == True or res_ids == False:
if isinstance(domain[i][2], bool):
def _rec_get(ids, table, parent): if not ids: return [] ids2 = table.search([ (parent, 'in', ids), (parent, '!=', False), ], order=[]) return ids + _rec_get(ids2, table, parent)
if res_ids == False:
if domain[i][2] == False:
def _rec_get(ids, table, parent): if not ids: return [] ids2 = table.search([ (parent, 'in', ids), (parent, '!=', False), ], order=[]) return ids + _rec_get(ids2, table, parent)
elif not res_ids: domain[i] = ('id', '=', '0')
def _rec_get(ids, table, parent): if not ids: return [] ids2 = table.search([ (parent, 'in', ids), (parent, '!=', False), ], order=[]) return ids + _rec_get(ids2, table, parent)
red_sql, red_ids = reduce_ids('"' + field.target + '"', res_ids) query1 = 'SELECT "' + field.origin + '" ' \ 'FROM "' + relation_obj._table + '" ' \ 'WHERE ' + red_sql query2 = red_ids
query1, query2 = target_obj.search([ (target_field, domain[i][1], domain[i][2]), ], order=[], query_string=True) query1 = ('SELECT "%s" FROM "%s" WHERE "%s" IN (%s)' % (field.origin, relation_obj._table, field.target, query1))
def _rec_get(ids, table, parent): if not ids: return [] ids2 = table.search([ (parent, 'in', ids), (parent, '!=', False), ], order=[]) return ids + _rec_get(ids2, table, parent)
for field2 in field_value[i]: if obj._columns[field2]._type \
for field2 in field_value[i].keys(): if field2 in obj._columns \ and obj._columns[field2]._type \
fld_def = (field in self._columns) and self._columns[field] \ or self._inherit_fields[field][2]
timestamp_field.sql_format),
timestamp_field.sql_format, self.create_date.string),
def init(self, cursor, module_name): super(ModelSQL, self).init(cursor, module_name)
timestamp_field.sql_format),
timestamp_field.sql_format, self.write_date.string),
def init(self, cursor, module_name): super(ModelSQL, self).init(cursor, module_name)
integer_field.sql_format),
integer_field.sql_format, self.create_uid.string),
def init(self, cursor, module_name): super(ModelSQL, self).init(cursor, module_name)
integer_field.sql_format),
integer_field.sql_format, self.write_uid.string),
def init(self, cursor, module_name): super(ModelSQL, self).init(cursor, module_name)
migrate=False, string=log[4])
migrate=False, string=log[3])
def init(self, cursor, module_name): super(ModelSQL, self).init(cursor, module_name)
if context is None: context = {} return context.get('resource')
return Transaction().context.get('resource')
def default_resource(self): if context is None: context = {} return context.get('resource')
datepart, timepart = date.split(" ") year, month, day = map(int, datepart.split("-")) timepart_full = timepart.split(".") hours, minutes, seconds = map(int, timepart_full[0].split(":")) if len(timepart_full) == 2: microseconds = int(timepart_full[1]) seconds += microseconds / 1000000.0 date = mx.DateTime.DateTime(year,...
if len(date) == 10: year, month, day = map(int, date.split('-')) date = datetime.date(year, month, day) else: datepart, timepart = date.split(" ") year, month, day = map(int, datepart.split("-")) timepart_full = timepart.split(".") hours, minutes, seconds = map(int, timepart_full[0].split(":")) if len(timepart_full) ==...
def extract(lookup_type, date): if date is None: return None try: datepart, timepart = date.split(" ") year, month, day = map(int, datepart.split("-")) timepart_full = timepart.split(".") hours, minutes, seconds = map(int, timepart_full[0].split(":")) if len(timepart_full) == 2: microseconds = int(timepart_full[1]) sec...
create(DB_NAME, USER_PASSWORD, 'en_US', CONFIG['admin_passwd'])
create(DB_NAME, CONFIG['admin_passwd'], 'en_US', USER_PASSWORD)
def install_module(name): ''' Install module for the tested database ''' database = Database().connect() cursor = database.cursor() databases = database.list(cursor) cursor.close() if DB_NAME not in databases: create(DB_NAME, USER_PASSWORD, 'en_US', CONFIG['admin_passwd']) cursor = DB.cursor() module_obj = POOL.get('ir...
if isinstance(domain[i], list):
arg = domain[i] if isinstance(arg, tuple) or \ (isinstance(arg, list) and len(arg) > 2 and \ arg[1] in OPERATORS): if arg[0] == 'active': active_found = True elif isinstance(arg, list):
def process(domain): i = 0 active_found = False while i < len(domain): if isinstance(domain[i], list): domain[i] = process(domain[i]) if isinstance(domain[i], tuple): if domain[i][0] == 'active': active_found = True i += 1 if not active_found: if domain and ((isinstance(domain[0], basestring) \ and domain[0] == 'AND') ...
if isinstance(domain[i], tuple): if domain[i][0] == 'active': active_found = True
def process(domain): i = 0 active_found = False while i < len(domain): if isinstance(domain[i], list): domain[i] = process(domain[i]) if isinstance(domain[i], tuple): if domain[i][0] == 'active': active_found = True i += 1 if not active_found: if domain and ((isinstance(domain[0], basestring) \ and domain[0] == 'AND') ...
self.assertRaises(Exception, test_view('ir'))
test_view('ir')
def test0010ir(self): ''' Test ir. ''' self.assertRaises(Exception, test_view('ir'))
self.assertRaises(Exception, test_view('res'))
test_view('res')
def test0020res(self): ''' Test res. ''' self.assertRaises(Exception, test_view('res'))
self.assertRaises(Exception, test_view('workflow'))
test_view('workflow')
def test0030workflow(self): ''' Test workflow. ''' self.assertRaises(Exception, test_view('workflow'))
self.assertRaises(Exception, test_view('webdav'))
test_view('webdav')
def test0040webdav(self): ''' Test webdav. ''' self.assertRaises(Exception, test_view('webdav'))
if child['left'] <= left: raise Exception('Record (%d): left %d <= parent left %d' % \ (child['id'], child['left'], left)) if child['left'] >= child['right']: raise Exception('Record (%d): left %d >= right %d' % \ (child['id'], child['left'], child['right'])) if right != 0 and child['right'] >= right: raise Exception('...
assert child['left'] > left, \ 'Record (%d): left %d <= parent left %d' % \ (child['id'], child['left'], left) assert child['left'] < child['right'], \ 'Record (%d): left %d >= right %d' % \ (child['id'], child['left'], child['right']) assert right == 0 or child['right'] < right, \ 'Record (%d): right %d >= parent righ...
def CheckTree(self, parent_id=False, left=0, right=0): child_ids = self.mptt.search([ ('parent', '=', parent_id), ], 0, None, None, CONTEXT) childs = self.mptt.read(child_ids, ['left', 'right'], CONTEXT) childs.sort(lambda x, y: cmp(child_ids.index(x['id']), child_ids.index(y['id']))) for child in childs: if child['lef...
if child['left'] <= next_left: raise Exception('Record (%d): left %d <= next left %d' % \ (child['id'], child['left'], next_left))
assert child['left'] > next_left, \ 'Record (%d): left %d <= next left %d' % \ (child['id'], child['left'], next_left)
def CheckTree(self, parent_id=False, left=0, right=0): child_ids = self.mptt.search([ ('parent', '=', parent_id), ], 0, None, None, CONTEXT) childs = self.mptt.read(child_ids, ['left', 'right'], CONTEXT) childs.sort(lambda x, y: cmp(child_ids.index(x['id']), child_ids.index(y['id']))) for child in childs: if child['lef...
if previous_right != 0 and child['right'] >= previous_right: raise Exception('Record (%d): right %d >= previous right %d' % \ (child['id'] , child['right'], previous_right))
assert previous_right == 0 or child['right'] < previous_right, \ 'Record (%d): right %d >= previous right %d' % \ (child['id'] , child['right'], previous_right)
def CheckTree(self, parent_id=False, left=0, right=0): child_ids = self.mptt.search([ ('parent', '=', parent_id), ], 0, None, None, CONTEXT) childs = self.mptt.read(child_ids, ['left', 'right'], CONTEXT) childs.sort(lambda x, y: cmp(child_ids.index(x['id']), child_ids.index(y['id']))) for child in childs: if child['lef...
self.assertRaises(Exception, self.CheckTree())
self.CheckTree()
def ReParent(self, parent_id=False): record_ids = self.mptt.search([ ('parent', '=', parent_id), ], 0, None, None, CONTEXT) if not record_ids: return for record_id in record_ids: for record2_id in record_ids: if record_id != record2_id: self.mptt.write(record_id, { 'parent': record2_id, }, CONTEXT) self.assertRaises(Ex...
self.assertRaises(Exception, self.CheckTree())
self.CheckTree()
def ReOrder(self, parent_id=False): record_ids = self.mptt.search([ ('parent', '=', parent_id), ], 0, None, None, CONTEXT) if not record_ids: return i = len(record_ids) for record_id in record_ids: self.mptt.write(record_id, { 'sequence': i, }, CONTEXT) i -= 1 self.assertRaises(Exception, self.CheckTree()) i = 0 for re...
self.assertRaises(Exception, self.CheckTree())
self.CheckTree()
def test0010create(self): ''' Create tree. ''' new_records = [False] for j in range(3): parent_records = new_records new_records = [] k = 0 for parent_record in parent_records: for i in range(3): record_id = self.mptt.create({ 'name': 'Test %d %d %d' % (j, k, i), 'parent': parent_record, }, CONTEXT) new_records.append(...
self.assertRaises(Exception, self.CheckTree())
self.CheckTree()
def test0040active(self): record_ids = self.mptt.search([], 0, None, None, CONTEXT) for record_id in record_ids: if record_id % 2: self.mptt.write(record_id, { 'active': False }, CONTEXT) self.assertRaises(Exception, self.CheckTree())
self.assertRaises(Exception, self.CheckTree())
self.CheckTree()
def test0050delete(self): ''' Delete. ''' record_ids = self.mptt.search([], 0, None, None, CONTEXT) for record_id in record_ids: if record_id % 2: self.mptt.delete(record_id, CONTEXT) self.assertRaises(Exception, self.CheckTree()) record_ids = self.mptt.search([], 0, None, None, CONTEXT) self.mptt.delete(record_ids[:le...
for i in self._inherits.keys(): value.update(self.pool.get(i).default_get(fields_names, with_rec_name=with_rec_name))
def default_get(self, fields_names, with_rec_name=True): ''' Return a dict with the default values for each field in fields_names.
for field in fields_names: if field in self._defaults and field not in self._inherit_fields: value[field] = self._defaults[field]() if field in self._columns: if self._columns[field]._type == 'boolean' and \ not field in value: value[field] = False if isinstance(self._columns[field], fields.Property): property_obj = se...
for field_name in fields_names: if field_name in self._defaults: value[field_name] = self._defaults[field_name]() if field_name in self._columns: field = self._columns[field_name] else: field = self._inherit_fields[field_name][2] if (field._type == 'boolean' and not field_name in value): value[field_name] = False if is...
def default_get(self, fields_names, with_rec_name=True): ''' Return a dict with the default values for each field in fields_names.
ir_default_obj = self.pool.get('ir.default') defaults = ir_default_obj.get_default(self._name, False) for field, field_value in defaults.items(): if field in fields_names: fld_def = (field in self._columns) and self._columns[field] \ or self._inherit_fields[field][2] if fld_def._type in ('many2one',): if not isinstance...
for name in (self._inherits.keys() + [self._name]): defaults = ir_default_obj.get_default(name, False) for field_name, field_value in defaults.items(): if field_name in fields_names: if field_name in self._columns: field = self._columns[field_name] else: field = self._inherit_fields[field_name][2] if field._type in ('m...
def default_get(self, fields_names, with_rec_name=True): ''' Return a dict with the default values for each field in fields_names.
('id', '=', field_value[i]),
('id', '=', field_value),
fld_def = (field in self._columns) and self._columns[field] \ or self._inherit_fields[field][2]
field_value2.append(field_value[i]) field_value = field_value2 if fld_def._type in ('one2many'): if not isinstance(field_value, list): continue obj = self.pool.get(fld_def.model_name) field_value2 = [] for i in range(len(field_value or [])): field_value2.append({}) for field2 in field_value[i].keys(): if field2 in obj....
if with_rec_name and 'rec_name' in obj._columns: value[field_name + '.rec_name'] = obj.browse( field_value).rec_name if field._type in ('many2many'): if not isinstance(field_value, list): continue obj = field.get_target(self.pool) field_value2 = [] for i in range(len(field_value)): if not hasattr(obj, 'search') \ or no...
fld_def = (field in self._columns) and self._columns[field] \ or self._inherit_fields[field][2]
).rec_name field_value2[i][field2] = field_value[i][field2] field_value = field_value2 value[field] = field_value
).rec_name) field_value2[i][field2] = field_value[i][field2] field_value = field_value2 value[field_name] = field_value
fld_def = (field in self._columns) and self._columns[field] \ or self._inherit_fields[field][2]
self.target: [('create', act[1])],
self.target: target_obj.create(cursor, user, act[1], context=context),
def set(self, cursor, user, record_id, model, name, values, context=None): ''' Set the values.
req_user = user_obj.browse(cron['request_user'])
def _callback(self, cron): try: args = (cron['args'] or []) and safe_eval(cron['args']) obj = self.pool.get(cron['model']) if not obj and hasattr(obj, cron['function']): return False fct = getattr(obj, cron['function']) fct(cron['user'], *args) except Exception, error: Transaction().cursor.rollback()
new_id = ir_model_data_obj._get_id(cursor,
new_id = ir_model_data_obj.get_id(cursor,
def process_liness(self, datas, prefix, fields_def, position=0): line = datas[position] row = {} translate = {} todo = [] warning = ''
new_id = ir_model_data_obj._get_id(cursor, user,
new_id = ir_model_data_obj.get_id(cursor, user,
def process_liness(self, datas, prefix, fields_def, position=0): line = datas[position] row = {} translate = {} todo = [] warning = ''
offset=0, limit=None, order=None, context=None, count=False)
offset=offset, limit=limit, order=order, context=context, count=count)
def search(self, cursor, user, domain, offset=0, limit=None, order=None, context=None, count=False): res = super(ModelSingleton, self).search(cursor, user, domain, offset=0, limit=None, order=None, context=None, count=False) if not res: if count: return 1 return [1] return res
query1, query2 = target_obj.search([
query1, query2 = target_obj.search(cursor, user, [
def _rec_get(ids, table, parent): if not ids: return [] ids2 = table.search(cursor, user, [(parent, 'in', ids), (parent, '!=', False)], order=[], context=context) return ids + _rec_get(ids2, table, parent)
], order=[], query_string=True)
], order=[], query_string=True, context=context)
def _rec_get(ids, table, parent): if not ids: return [] ids2 = table.search(cursor, user, [(parent, 'in', ids), (parent, '!=', False)], order=[], context=context) return ids + _rec_get(ids2, table, parent)
res_ids = [x[0] for x in target_obj.search(cursor, user, [ ('rec_name', domain[i][1], domain[i][2]), ], context=context)]
res_ids = target_obj.search(cursor, user, [ ('rec_name', domain[i][1], domain[i][2]), ], context=context)
def _rec_get(ids, table, parent): if not ids: return [] ids2 = table.search(cursor, user, [(parent, 'in', ids), (parent, '!=', False)], context=context) return ids + _rec_get(ids2, table, parent)
return ('id', 'in', [x[0] for x in cursor.fetchall()])
return [('id', 'in', [x[0] for x in cursor.fetchall()])]
def search_model(self, cursor, user, name, clause, context=None): cursor.execute('SELECT id FROM "%s" ' 'WHERE split_part(name, \',\', 1) %s %%s' % (self._table, clause[1]), (clause[2],)) return ('id', 'in', [x[0] for x in cursor.fetchall()])
'of table %s not null!' % \
'of table %s!' % \
def alter_size(self, column_name, column_type): logging.getLogger('init').warning( 'Unable to alter size of column %s ' \ 'of table %s not null!' % \ (column_name, self.table_name))
'of table %s not null!' % \
'of table %s!' % \
def alter_type(self, column_name, column_type): logging.getLogger('init').warning( 'Unable to alter type of column %s ' \ 'of table %s not null!' % \ (column_name, self.table_name))
'of table %s not null!' % \
'of table %s!' % \
def db_default(self, column_name, value): logging.getLogger('init').warning( 'Unable to set default on column %s ' \ 'of table %s not null!' % \ (column_name, self.table_name))
with Transaction.set_user(0):
with Transaction().set_user(0):
def set_preferences(self, values, old_password=False): ''' Set user preferences.