def file_to_tomboy_note(self, f, **kwargs): title, ext = f.get_filename_and_extension() text = f.get_contents_as_text() #A tomboy formatted XML file if text.startswith('<?xml version="1.0"') and text.find( 'xmlns="http://beatniksoftware.com/tomboy">') > 0: note = TomboyNote(title=Utils.xml_extract_value_from_tag( "title", text), contents=None, xml=text) #A bog standard text file else: note = TomboyNote(title=title, contents=text, xml=None) return note
def file_to_tomboy_note(self, f, **kwargs): title,ext = f.get_filename_and_extension() text = f.get_contents_as_text() #A tomboy formatted XML file if text.startswith('<?xml version="1.0"') and text.find('xmlns="http://beatniksoftware.com/tomboy">') > 0: note = TomboyNote( title=Utils.xml_extract_value_from_tag("title", text), contents=None, xml=text ) #A bog standard text file else: note = TomboyNote( title=title, contents=text, xml=None ) return note
ok("Datetime to unix timestamp", Utils.datetime_get_timestamp(dt) == ts) ok("Unix timestamp to datetime", Utils.datetime_from_timestamp(ts) == dt) m = Memstats.Memstats() VmSize,VmRSS,VmStack = m.calculate() ok("Memstats: size:%s rss:%s stack:%s" % (VmSize,VmRSS,VmStack), VmSize > 0 and VmRSS > 0 and VmStack > 0) # Test the shiny command line executer conv = CommandLineConverter.CommandLineConverter() conv.build_command("ls %s %s") cmdok,output = conv.convert("/tmp","/dev/null",callback=None,save_output=True) ok("Command executed ok", cmdok == True and len(output) > 0) ok("Simple xml tag extractor", Utils.xml_extract_value_from_tag("tag", "<tag>foo tag bar</tag>") == "foo tag bar") ok("Simple xml tag extractor", Utils.xml_extract_value_from_tag("tag", "<nottag>tag</nottag>") == None) info = Utils.get_module_information(os, None) ok("Library Information: %s" % info, len(info) > 0) info = Utils.get_module_information(sys, 'version_info') ok("System Information: %s" % info, len(info) > 0) class A(Singleton.Singleton): def __init__(self): Singleton.Singleton.__init__(self) self.i = random.random() def num(self): return self.i