def load_map_and_media_as_atlas_objects(makefile): prefix, file = os.path.split(makefile) if prefix: prefix = prefix + os.sep sources = read_file(makefile)[0] all_objects = combine_files(sources.world_sources, prefix) #CHEAT: does only this special case ... if hasattr(sources, "world_sources_operations") and sources.world_sources_operations: file_as_operations(all_objects, sources.world_sources_operations[0][5:]) all_media_info_dict = combine_files(sources.media_sources, prefix) return all_objects, all_media_info_dict base_definitions = read_file_as_dict("../../../protocols/atlas/spec/atlas.atlas") class_definitions = read_file_as_dict("../examples/meadow_class.atlas") objects = read_file_as_dict("../examples/meadow.atlas") all_objects = {} all_objects.update(base_definitions) all_objects.update(class_definitions) all_objects.update(objects) fill_attributes(all_objects.values()) media_info_dict = read_file_as_dict("../examples/meadow_media.atlas") all_media_info_dict = {} all_media_info_dict.update(base_definitions) all_media_info_dict.update(media_info_dict) fill_attributes(all_media_info_dict.values()) return all_objects, all_media_info_dict
def load_map_and_media_as_atlas_objects(makefile): prefix, file = os.path.split(makefile) if prefix: prefix = prefix + os.sep sources = read_file(makefile)[0] all_objects = combine_files(sources.world_sources, prefix) #CHEAT: does only this special case ... if hasattr(sources, "world_sources_operations") and sources.world_sources_operations: file_as_operations(all_objects, sources.world_sources_operations[0][5:]) all_media_info_dict = combine_files(sources.media_sources, prefix) return all_objects, all_media_info_dict base_definitions = read_file_as_dict("../../../protocols/atlas/spec/atlas.atlas") class_definitions = read_file_as_dict("../examples/meadow_class.atlas") objects = read_file_as_dict("../examples/meadow.atlas") all_objects = {} all_objects.update(base_definitions) all_objects.update(class_definitions) all_objects.update(objects) fill_attributes(list(all_objects.values())) media_info_dict = read_file_as_dict("../examples/meadow_media.atlas") all_media_info_dict = {} all_media_info_dict.update(base_definitions) all_media_info_dict.update(media_info_dict) fill_attributes(list(all_media_info_dict.values())) return all_objects, all_media_info_dict
def file_as_operations(dict, file): for op in read_file(file): if op.parents[0]=="create": obj = op.arg #dict[obj.loc].contains.append(obj.id) dict[obj.loc].contains.insert(0, obj.id) dict[obj.id] = obj for i in range(len(obj.parents)): obj.parents[i] = dict[obj.parents[i]] print(obj)
def file_as_operations(dict, file): for op in read_file(file): if op.parents[0]=="create": obj = op.arg #dict[obj.loc].contains.append(obj.id) dict[obj.loc].contains.insert(0, obj.id) dict[obj.id] = obj for i in range(len(obj.parents)): obj.parents[i] = dict[obj.parents[i]] print obj
############################################################ # test from file co.set_stream_mode() file_name = "test." + file_extension file_content = open(file_name).read() neg1 = NegotiationClient([codec_id]) assert (neg1(file_content) == "found") str1 = co.encode(msg) + co.encoder.close() if neg1.str != str1: print(codec_id + " encoding not same!") msg2 = co.decode(str1) file_content = open(file_name).read() neg2 = NegotiationClient([codec_id]) assert (neg2(file_content) == "found") str2 = co.encode(msg2) + co.encoder.close() if neg2.str != str2: print("%(codec_id)s decoding and %(codec_id)s encoding not same!" % locals()) assert (co.decoder.eos()) ############################################################ # test file.py (and bridge) objects = read_file(file_name) assert (str(objects) == str(msg)) except: print("Exception testing codec", codec_id) raise
#Lesser General Public License for more details. #You should have received a copy of the GNU Lesser General Public #License along with this library; if not, write to the Free Software #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA debug_flag = 0 from types import * from copy import deepcopy import string import atlas import atlas.analyse from atlas.transport.file import read_file #generated by gen_simple_core.py or from http://purple.worldforge.org/~aloril/atlas/simple_core.atlas meadow_map = read_file("../reference/simple_core.atlas") #print len(meadow_map), type(meadow_map) obj_dict = {} for obj in meadow_map: obj_dict[obj.id] = obj def get_absolute_points_and_ids(obj): lst = [] def combine(a,b): return tuple(a),b dict = {} if hasattr(obj, "_polyline"): lst = lst + map(combine, obj._polyline, obj.polyline_ids) if hasattr(obj, "_area") and obj._area:
#Lesser General Public License for more details. #You should have received a copy of the GNU Lesser General Public #License along with this library; if not, write to the Free Software #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA debug_flag = 0 from types import * from copy import deepcopy import string import atlas import atlas.analyse from atlas.transport.file import read_file #generated by gen_simple_core.py or from http://purple.worldforge.org/~aloril/atlas/simple_core.atlas meadow_map = read_file("../reference/simple_core.atlas") #print len(meadow_map), type(meadow_map) obj_dict = {} for obj in meadow_map: obj_dict[obj.id] = obj def get_absolute_points_and_ids(obj): lst = [] def combine(a, b): return tuple(a), b dict = {} if hasattr(obj, "_polyline"):
def setup(self): self.objects = read_file(file_name)
############################################################ # test from file co.set_stream_mode() file_name = "test." + file_extension file_content = open(file_name).read() neg1 = NegotiationClient([codec_id]) assert(neg1(file_content)=="found") str1 = co.encode(msg)+co.encoder.close() if neg1.str != str1: print codec_id + " encoding not same!" msg2 = co.decode(str1) file_content = open(file_name).read() neg2 = NegotiationClient([codec_id]) assert(neg2(file_content)=="found") str2 = co.encode(msg2)+co.encoder.close() if neg2.str != str2: print "%(codec_id)s decoding and %(codec_id)s encoding not same!" % locals() assert(co.decoder.eos()) ############################################################ # test file.py (and bridge) objects = read_file(file_name) assert(str(objects)==str(msg)) except: print "Exception testing codec", codec_id raise