function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def __init__(self, partition, prefix='Rte', include=None, mode_switch=True, os_enable=True): self.partition=partition self.includes = [] #array of tuples, first element is the name of include header, second element is True if this is a sysinclude self.prefix=prefix self.com_component = None ...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def generate(self, dest_dir='.'): if self.os_enable: self.extra_static_vars.update(self.partition.static_vars) self._generate_header(dest_dir, 'RteApi.h') self._generate_source(dest_dir, 'RteApi.c')
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _generate_header(self, dest_dir='.', file_name=None): if file_name is None: file_name = 'RteApi.h' self.includes.append((file_name, False)) file_path = os.path.join(dest_dir,file_name) with io.open(file_path, 'w', newline='\n') as fp: header = C.hfile(file_path)...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _generate_source(self, dest_dir='.', file_name=None): if file_name is None: file_name = 'RteApi.c' file_path = os.path.join(dest_dir,file_name) with io.open(file_path, 'w', newline='\n') as fp: self._write_includes(fp) self._write_constants_and_typedefs(fp) ...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _write_includes(self, fp): lines = _genCommentHeader('Includes') fp.write('\n'.join(lines)+'\n') code = C.sequence() for include in self.includes: code.append(C.include(*include)) if self.com_component is not None: code.append(C.include(self.com_component.name+...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _write_constants_and_typedefs(self, fp): fp.write('\n'.join(_genCommentHeader('Constants and Types'))+'\n\n')
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _write_local_vars(self, fp): fp.write('\n'.join(_genCommentHeader('Local Variables'))+'\n') code = C.sequence() for data_element in sorted(self.partition.data_element_map.values(), key=lambda x: x.symbol): var = C.variable(data_element.symbol, data_element.dataType.name, True) ...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _write_public_funcs(self, fp): fp.write('\n'.join(_genCommentHeader('Public Functions'))+'\n') self._write_rte_start(fp) if len(self.partition.upperLayerAPI.read)>0: self._genRead(fp, sorted(self.partition.upperLayerAPI.final['read'], key=lambda x: x.shortname)) if len(sel...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _write_rte_start(self, fp): func = C.function(self.prefix+'_Start', 'void') body = C.block(innerIndent=innerIndentDefault) self._write_init_values(body) if len(self.extra_rte_start)>0: body.extend(self.extra_rte_start) fp.write(str(func)+'\n') fp.write('\n'.join(b...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _write_init_values(self, body): for data_element in sorted(self.partition.data_element_map.values(), key=lambda x: x.symbol): if data_element.initValue is not None: init_str = autosar.constant.initializer_string(data_element.initValue) body.code.append(C.statement('%s = %s...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _genRead(self, fp, prototypes): """Generates all Rte_Read functions""" for port_func in prototypes: body = C.block(innerIndent=innerIndentDefault) if port_func.data_element.com_access['Receive'] is not None: com_func = port_func.data_element.com_access['Receive'] ...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _genWrite(self, fp, prototypes): for port_func in prototypes: hasComSignal = False body = C.block(innerIndent=innerIndentDefault) if port_func.data_element.symbol is not None: body.code.append(C.statement('%s = %s'%(port_func.data_element.symbol, port_func.proto.arg...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _genReceive(self, fp, prototypes): for proto in prototypes: body = C.block(innerIndent=innerIndentDefault) body.code.append(C.statement('return RTE_E_OK')) fp.write(str(proto.func)+'\n') fp.write('\n'.join(body.lines())+'\n\n')
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _genSend(self, fp, prototypes): for proto in prototypes: body = C.block(innerIndent=innerIndentDefault) body.code.append(C.statement('return RTE_E_OK')) fp.write(str(proto.func)+'\n') fp.write('\n'.join(body.lines())+'\n\n')
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _genCall(self, fp, prototypes): for proto in prototypes: body = C.block(innerIndent=innerIndentDefault) body.code.append(C.statement('return RTE_E_OK')) fp.write(str(proto.func)+'\n') fp.write('\n'.join(body.lines())+'\n\n')
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _genGet(self, fp, prototypes): for port_func in prototypes: body = C.block(innerIndent=innerIndentDefault) prefix = '&' if port_func.data_element.dataType.isComplexType else '' suffix = '[0]' if isinstance(port_func.data_element.dataType, autosar.datatype.ArrayDataType) else '' ...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _genFunctionBodies(self, fp, prototypes): for func in prototypes: fp.write(str(func.proto)+'\n') fp.write('\n'.join(func.body.lines())+'\n\n')
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _write_header_includes(self, code): code.extend(_genCommentHeader2("INCLUDES")) code.append(C.include('Rte_Type.h')) code.append(C.include('Rte.h'))
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _write_header_public_func(self, code): code.append('') code.extend(_genCommentHeader2("PUBLIC FUNCTION PROTOTYPES")) code.append(C.statement(C.function('Rte_Start', 'void'))) if self.mode_switch_enable and len(self.partition.mode_switch_functions)>0: for func in [self.par...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def __init__(self, partition): self.partition = partition self.useMockedAPI=False
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def generate(self, destdir, mocked=None): if mocked is not None: self.useMockedAPI=bool(mocked) for component in self.partition.components: if not isinstance(component.inner, autosar.bsw.com.ComComponent): with io.open(os.path.join(destdir, 'Rte_%s.h'%component.inner.name)...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _genComponentHeader(self, fp, component): ws = component.inner.rootWS() assert(ws is not None) hfile=C.hfile(None, guard='RTE_%s_H'%(component.inner.name.upper())) hfile.code.append(C.include('Rte.h')) hfile.code.append(C.include('Rte_Type.h')) hfile.code.append(C.blank()) ...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _genInitValues(self, ws, ports): ports = sorted(ports, key=lambda port: port.name) code = C.sequence() for port in ports: for comspec in port.comspec: if isinstance(comspec, autosar.port.DataElementComSpec): if comspec.initValueRef is not None: ...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _getInitValue(self, ws, def_name, value, dataType): """ returns a list or sequence """ code = C.sequence() if isinstance(value, autosar.constant.IntegerValue): if dataType.minVal>=0: suffix='u' else: suffix='' code.append(C.d...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _writeRunnableProto(self, runnable): lines = [] lines.extend([C.line(x) for x in _genCommentHeader('Runnable %s'%runnable.name)]) lines.append(C.statement(runnable.prototype)) lines.append(C.blank()) return lines
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def __init__(self, partition, api_prefix='Rte', file_prefix = 'MockRte', include=None, mode_switch=False, os_enable=False): super().__init__(partition, api_prefix, include, mode_switch) self.includes.append((file_prefix+'.h', False)) self.api_prefix = api_prefix self.file_prefix ...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def generate(self, dest_dir): self._generateHeader(dest_dir) super()._generate_source(dest_dir, self.file_prefix+'.c')
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _create_port_getter_api(self, port): component = port.parent for data_element in port.data_elements: if "%s/%s"%(port.name, data_element.name) in component.data_element_port_access: self._create_data_element_getter(component, port, data_element)
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _create_data_element_getter(self, component, port, data_element): data_type = data_element.dataType func_name='%s_GetWriteData_%s_%s_%s'%(self.prefix, component.name, port.name, data_element.name) short_name='%s_GetWriteData_%s_%s'%(self.prefix, port.name, data_element.name) suffix = '*'...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _create_port_setter_api(self, port): component = port.parent for data_element in port.data_elements: if "%s/%s"%(port.name, data_element.name) in component.data_element_port_access: self._create_data_element_setter(component, port, data_element) for operation in port.oper...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _create_data_element_setter(self, component, port, data_element): var_name = self._createDataElementVariable(component, port, data_element) port_func = autosar.rte.base.SetReadDataFunction(self.prefix, component, port, data_element, var_name) self.partition.upperLayerAPI.setReadData[port_func.s...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _create_operation_setter(self, component, port, operation, port_access): func_name='%s_SetCallHandler_%s_%s_%s'%(self.prefix, component.name, port.name, operation.name) short_name='%s_SetCallHandler_%s_%s'%(self.prefix, port.name, operation.name)
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _createMockServerCallFunction(self, proto, var_name): body = C.block(innerIndent=innerIndentDefault) body.append(C.line('if (%s != 0)'%(var_name))) inner = C.block(innerIndent=innerIndentDefault) fcall = C.fcall(var_name) for arg in proto.args: fcall.add_param(arg.name) ...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _createDataElementVariable(self, component, port, data_element): data_element_map = self.partition.data_element_map variable_name = '_'.join([component.name, port.name, data_element.name]) if variable_name not in data_element_map: data_element.symbol = variable_name data_ele...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _generateHeader(self, dest_dir): filepath = os.path.join(dest_dir,self.file_prefix+'.h') with io.open(filepath, 'w', newline='\n') as fp: for line in self._createHeaderLines(filepath): fp.write(line) fp.write('\n') fp.write('\n')
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _createHeaderLines(self, filepath): hfile = C.hfile(filepath) code = hfile.code code.extend([C.line(x) for x in _genCommentHeader('Includes')]) code.append(C.include("Std_Types.h")) code.append(C.include("Rte_Type.h")) code.append(C.include("Rte.h")) code.append(C.bl...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def __init__(self, partition, os_cfg, prefix='RteTask', include=None): self.partition = partition self.prefix = prefix self.os_cfg = os_cfg self.includes = [ #array of tuples, first element is the name of include header, second element is True if this is a sysinclude ...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def generate(self, dest_dir='.'): #self._generate_header(dest_dir) self._generate_source(dest_dir)
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _generate_source(self, dest_dir): file_name = self.prefix+'.c' file_path = os.path.join(dest_dir,file_name)
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _write_source_includes(self): code = C.sequence() code.extend(_genCommentHeader2('INCLUDES')) code.append(C.blank()) for include in self.includes: code.append(C.include(*include)) code.append(C.blank()) return code
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _write_source_constants_and_typedefs(self): code = C.sequence() code.extend(_genCommentHeader2('CONSTANTS AND DATA TYPES')) code.append(C.blank()) return code
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _write_source_local_funcs(self): code = C.sequence() code.extend(_genCommentHeader2('LOCAL FUNCTION PROTOTYPES')) code.append(C.blank()) return code
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _write_source_global_funcs(self): code = C.sequence() code.extend(_genCommentHeader2('GLOBAL FUNCTIONS')) code.append(C.blank()) for task in sorted(self.os_cfg.tasks, key=lambda x: x.name): code.append(C.line('OS_TASK_HANDLER({0.name}, arg)'.format(task))) ...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _generate_task_body(self, task): code = C.block(innerIndent=innerIndentDefault) isRunning=C.variable('isRunning', 'boolean') code.append(C.statement('{0} = TRUE'.format(str(isRunning)))) code.append(C.statement('os_task_t *self = (os_task_t*)arg')) code.append('') code.appe...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _generate_event_mask_triggers(self, task): code = C.sequence() for runnable in task.runnables: if runnable.processed: continue matching_runnables = self._find_compatible_runnables(task, runnable) self._generate_runnable_calls(code, matching_runnables) ...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _find_compatible_runnables(self, task, current): result = [current] for other in task.runnables: if (other is not current) and (not other.processed): if len(current.event_triggers) == len(other.event_triggers): is_compatible = True for current_eve...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _generate_runnable_calls(self, code, matching_runnables): events = matching_runnables[0].event_triggers if len(events) == 1: event = events[0] if not isinstance(event, autosar.rte.base.OperationInvokedEvent): code.append(C.line('if (eventMask & %s)'%event.symbol)) ...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _generate_header(self, dest_dir): file_name = self.prefix+'.h' file_path = os.path.join(dest_dir,file_name) with io.open(file_path, 'w', newline='\n') as fp: print("#ifndef RTE_TASK_H", file=fp) print("#define RTE_TASK_H", file=fp) self._write_header_includes(fp) ...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _write_header_includes(self, fp): lines = _genCommentHeader('INCLUDES') lines.append('#ifdef _MSC_VER') lines.append('#include <Windows.h>') lines.append('#else') lines.append('#include <pthread.h>') lines.append('#endif //_MSC_VER') lines.append('#include "osmacro.h...
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _write_header_constants_and_typedefs(self, fp): lines = _genCommentHeader('CONSTANTS AND DATA TYPES') fp.write('\n'.join(lines)+'\n\n')
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def _write_header_global_var(self, fp): lines = _genCommentHeader('GLOBAL VARIABLES') fp.write('\n'.join(lines)+'\n\n')
cogu/autosar
[ 233, 130, 233, 19, 1469005526 ]
def __init__(self, editwin): self.editwin = editwin
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def format_paragraph_event(self, event, limit=None): """Formats paragraph to a max width specified in idleConf. If text is selected, format_paragraph_event will start breaking lines at the max width, starting from the beginning selection. If no text is selected, format_paragraph_event ...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def reformat_paragraph(data, limit): """Return data reformatted to specified width (limit).""" lines = data.split("\n") i = 0 n = len(lines) while i < n and is_all_white(lines[i]): i = i+1 if i >= n: return data indent1 = get_indent(lines[i]) if i+1 < n and not is_all_whi...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def is_all_white(line): """Return True if line is empty or all whitespace.""" return re.match(r"^\s*$", line) is not None
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def get_comment_header(line): """Return string with leading whitespace and '#' from line or ''. A null return indicates that the line is not a comment line. A non- null return, such as ' #', will be used to find the other lines of a comment block with the same indent. """ m = re.match(r"^([...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def __init__(self, editwin): self.editwin = editwin
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def format_paragraph_event(self, event, limit=None): """Formats paragraph to a max width specified in idleConf. If text is selected, format_paragraph_event will start breaking lines at the max width, starting from the beginning selection. If no text is selected, format_paragraph_event ...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def reformat_paragraph(data, limit): """Return data reformatted to specified width (limit).""" lines = data.split("\n") i = 0 n = len(lines) while i < n and is_all_white(lines[i]): i = i+1 if i >= n: return data indent1 = get_indent(lines[i]) if i+1 < n and not is_all_whi...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def is_all_white(line): """Return True if line is empty or all whitespace.""" return re.match(r"^\s*$", line) is not None
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def get_comment_header(line): """Return string with leading whitespace and '#' from line or ''. A null return indicates that the line is not a comment line. A non- null return, such as ' #', will be used to find the other lines of a comment block with the same indent. """ m = re.match(r"^([...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def __init__(self, editwin): self.editwin = editwin
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def format_paragraph_event(self, event, limit=None): """Formats paragraph to a max width specified in idleConf. If text is selected, format_paragraph_event will start breaking lines at the max width, starting from the beginning selection. If no text is selected, format_paragraph_event ...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def reformat_paragraph(data, limit): """Return data reformatted to specified width (limit).""" lines = data.split("\n") i = 0 n = len(lines) while i < n and is_all_white(lines[i]): i = i+1 if i >= n: return data indent1 = get_indent(lines[i]) if i+1 < n and not is_all_whi...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def is_all_white(line): """Return True if line is empty or all whitespace.""" return re.match(r"^\s*$", line) is not None
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def get_comment_header(line): """Return string with leading whitespace and '#' from line or ''. A null return indicates that the line is not a comment line. A non- null return, such as ' #', will be used to find the other lines of a comment block with the same indent. """ m = re.match(r"^([...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def tearDown(self): try: os.unlink(support.TESTFN) except: pass
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_create(self): pl = self._create() self.assertEqual(pl["aString"], "Doodah") self.assertEqual(pl["aDict"]["aFalseValue"], False)
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_invalid_type(self): pl = [ object() ] for fmt in ALL_FORMATS: with self.subTest(fmt=fmt): self.assertRaises(TypeError, plistlib.dumps, pl, fmt=fmt)
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_bytes(self): pl = self._create() data = plistlib.dumps(pl) pl2 = plistlib.loads(data) self.assertNotIsInstance(pl, plistlib._InternalDict) self.assertEqual(dict(pl), dict(pl2)) data2 = plistlib.dumps(pl2) self.assertEqual(data, data2)
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_indentation_dict(self): data = {'1': {'2': {'3': {'4': {'5': {'6': {'7': {'8': {'9': b'aaaaaa'}}}}}}}}} self.assertEqual(plistlib.loads(plistlib.dumps(data)), data)
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_appleformatting(self): for use_builtin_types in (True, False): for fmt in ALL_FORMATS: with self.subTest(fmt=fmt, use_builtin_types=use_builtin_types): pl = plistlib.loads(TESTDATA[fmt], use_builtin_types=use_builtin_types) ...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_bytesio(self): for fmt in ALL_FORMATS: with self.subTest(fmt=fmt): b = BytesIO() pl = self._create(fmt=fmt) plistlib.dump(pl, b, fmt=fmt) pl2 = plistlib.load(BytesIO(b.getvalue()), fmt=fmt) self.assertEqual(dict...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_keysort(self): pl = collections.OrderedDict() pl['b'] = 1 pl['a'] = 2 pl['c'] = 3 for fmt in ALL_FORMATS: for sort_keys in (False, True): with self.subTest(fmt=fmt, sort_keys=sort_keys): data = plistlib.dumps(pl, fmt=fmt, ...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_skipkeys(self): pl = { 42: 'aNumber', 'snake': 'aWord', } for fmt in ALL_FORMATS: with self.subTest(fmt=fmt): data = plistlib.dumps( pl, fmt=fmt, skipkeys=True, sort_keys=False) pl2 = plistlib.load...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_list_members(self): pl = { 'first': [1, 2], 'second': [1, 2], 'third': [3, 4], } for fmt in ALL_FORMATS: with self.subTest(fmt=fmt): data = plistlib.dumps(pl, fmt=fmt) pl2 = plistlib.loads(data) ...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_controlcharacters(self): for i in range(128): c = chr(i) testString = "string containing %s" % c if i >= 32 or c in "\r\n\t": # \r, \n and \t are the only legal control chars in XML plistlib.dumps(testString, fmt=plistlib.FMT_XML) ...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_invalidarray(self): for i in ["<key>key inside an array</key>", "<key>key inside an array2</key><real>3</real>", "<true/><key>key inside an array3</key>"]: self.assertRaises(ValueError, plistlib.loads, ("<plist><array>%s</arr...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_invalidinteger(self): self.assertRaises(ValueError, plistlib.loads, b"<plist><integer>not integer</integer></plist>")
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_xml_encodings(self): base = TESTDATA[plistlib.FMT_XML] for xml_encoding, encoding, bom in [ (b'utf-8', 'utf-8', codecs.BOM_UTF8), (b'utf-16', 'utf-16-le', codecs.BOM_UTF16_LE), (b'utf-16', 'utf-16-be', codecs.BOM_UTF16_BE), ...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_io_deprecated(self): pl_in = { 'key': 42, 'sub': { 'key': 9, 'alt': 'value', 'data': b'buffer', } } pl_out = plistlib._InternalDict({ 'key': 42, 'sub': plistlib._InternalDict({ ...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_dataobject_deprecated(self): in_data = { 'key': plistlib.Data(b'hello') } out_data = { 'key': b'hello' } buf = plistlib.dumps(in_data) cur = plistlib.loads(buf) self.assertEqual(cur, out_data) self.assertNotEqual(cur, in_data) cur = plistlib.loads(buf,...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def tearDown(self): try: os.unlink(support.TESTFN) except: pass
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_create(self): pl = self._create() self.assertEqual(pl["aString"], "Doodah") self.assertEqual(pl["aDict"]["aFalseValue"], False)
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_invalid_type(self): pl = [ object() ] for fmt in ALL_FORMATS: with self.subTest(fmt=fmt): self.assertRaises(TypeError, plistlib.dumps, pl, fmt=fmt)
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_bytes(self): pl = self._create() data = plistlib.dumps(pl) pl2 = plistlib.loads(data) self.assertNotIsInstance(pl, plistlib._InternalDict) self.assertEqual(dict(pl), dict(pl2)) data2 = plistlib.dumps(pl2) self.assertEqual(data, data2)
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_indentation_dict(self): data = {'1': {'2': {'3': {'4': {'5': {'6': {'7': {'8': {'9': b'aaaaaa'}}}}}}}}} self.assertEqual(plistlib.loads(plistlib.dumps(data)), data)
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_appleformatting(self): for use_builtin_types in (True, False): for fmt in ALL_FORMATS: with self.subTest(fmt=fmt, use_builtin_types=use_builtin_types): pl = plistlib.loads(TESTDATA[fmt], use_builtin_types=use_builtin_types) ...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_bytesio(self): for fmt in ALL_FORMATS: with self.subTest(fmt=fmt): b = BytesIO() pl = self._create(fmt=fmt) plistlib.dump(pl, b, fmt=fmt) pl2 = plistlib.load(BytesIO(b.getvalue()), fmt=fmt) self.assertEqual(dict...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_keysort(self): pl = collections.OrderedDict() pl['b'] = 1 pl['a'] = 2 pl['c'] = 3 for fmt in ALL_FORMATS: for sort_keys in (False, True): with self.subTest(fmt=fmt, sort_keys=sort_keys): data = plistlib.dumps(pl, fmt=fmt, ...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_skipkeys(self): pl = { 42: 'aNumber', 'snake': 'aWord', } for fmt in ALL_FORMATS: with self.subTest(fmt=fmt): data = plistlib.dumps( pl, fmt=fmt, skipkeys=True, sort_keys=False) pl2 = plistlib.load...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_list_members(self): pl = { 'first': [1, 2], 'second': [1, 2], 'third': [3, 4], } for fmt in ALL_FORMATS: with self.subTest(fmt=fmt): data = plistlib.dumps(pl, fmt=fmt) pl2 = plistlib.loads(data) ...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_controlcharacters(self): for i in range(128): c = chr(i) testString = "string containing %s" % c if i >= 32 or c in "\r\n\t": # \r, \n and \t are the only legal control chars in XML plistlib.dumps(testString, fmt=plistlib.FMT_XML) ...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_invalidarray(self): for i in ["<key>key inside an array</key>", "<key>key inside an array2</key><real>3</real>", "<true/><key>key inside an array3</key>"]: self.assertRaises(ValueError, plistlib.loads, ("<plist><array>%s</arr...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_invalidinteger(self): self.assertRaises(ValueError, plistlib.loads, b"<plist><integer>not integer</integer></plist>")
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_xml_encodings(self): base = TESTDATA[plistlib.FMT_XML] for xml_encoding, encoding, bom in [ (b'utf-8', 'utf-8', codecs.BOM_UTF8), (b'utf-16', 'utf-16-le', codecs.BOM_UTF16_LE), (b'utf-16', 'utf-16-be', codecs.BOM_UTF16_BE), ...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_io_deprecated(self): pl_in = { 'key': 42, 'sub': { 'key': 9, 'alt': 'value', 'data': b'buffer', } } pl_out = plistlib._InternalDict({ 'key': 42, 'sub': plistlib._InternalDict({ ...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_dataobject_deprecated(self): in_data = { 'key': plistlib.Data(b'hello') } out_data = { 'key': b'hello' } buf = plistlib.dumps(in_data) cur = plistlib.loads(buf) self.assertEqual(cur, out_data) self.assertNotEqual(cur, in_data) cur = plistlib.loads(buf,...
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def tearDown(self): try: os.unlink(support.TESTFN) except: pass
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]
def test_create(self): pl = self._create() self.assertEqual(pl["aString"], "Doodah") self.assertEqual(pl["aDict"]["aFalseValue"], False)
ArcherSys/ArcherSys
[ 3, 2, 3, 16, 1412356452 ]