Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _main(self):
"""
get's automatically called from Memacs class
read the lines from sms backup xml file,
parse and write them to org file
"""
data = CommonReader.get_data_from_file(self._args.smsxmlfile)
try:
xml.sax.parseString(data.encode('utf-8'),
SmsSaxHandler(self._writer,
self._args.ignore_incoming,
self._args.ignore_outgoing))
except SAXParseException:
logging.error("No correct XML given")
sys.exit(1)
def _main(self):
"""
get's automatically called from Memacs class
read the lines from svn xml file, parse and write them to org file
"""
# read file
if self._args.svnlogxmlfile:
logging.debug("using as %s input_stream", self._args.svnlogxmlfile)
data = CommonReader.get_data_from_file(self._args.svnlogxmlfile)
else:
logging.info("Using stdin as input_stream")
data = CommonReader.get_data_from_stdin()
try:
xml.sax.parseString(data.encode('utf-8'),
SvnSaxHandler(self._writer,
self._args.grepauthor))
except SAXParseException:
logging.error("No correct XML given")
sys.exit(1)
## NOTE: this is a dirty hack to prevent te XML parser from complainaing about
## encoding issues of UTF-8 encoded emojis. Will be reverted when parsing sms_body
outputhandle.write(line.replace('&#', 'EnCoDiNgHaCk42') + '\n')
except IOError as e:
print("tempfile line " + str(line_number) + " [" + str(temp_xml_file) + "]")
print("I/O error({0}): {1}".format(e.errno, e.strerror))
except ValueError as e:
print("tempfile line " + str(line_number) + " [" + str(temp_xml_file) + "]")
print("Value error: {0}".format(e))
#print "line [%s]" % str(line)
except:
print("tempfile line " + str(line_number) + " [" + str(temp_xml_file) + "]")
print("Unexpected error:", sys.exc_info()[0])
raise
data = CommonReader.get_data_from_file(temp_xml_file)
try:
xml.sax.parseString(data.encode('utf-8'),
SmsSaxHandler(self._writer,
self._args.ignore_incoming,
self._args.ignore_outgoing,
self._numberdict))
except SAXParseException:
logging.error("No correct XML given")
sys.exit(1)
else:
os.remove(temp_xml_file)
def _main(self):
"""
get's automatically called from Memacs class
read the lines from svn xml file, parse and write them to org file
"""
# read file
if self._args.svnlogxmlfile:
logging.debug("using as %s input_stream", self._args.svnlogxmlfile)
data = CommonReader.get_data_from_file(self._args.svnlogxmlfile)
else:
logging.info("Using stdin as input_stream")
data = CommonReader.get_data_from_stdin()
try:
xml.sax.parseString(data.encode('utf-8'),
SvnSaxHandler(self._writer,
self._args.grepauthor))
except SAXParseException:
logging.error("No correct XML given")
sys.exit(1)
def _main(self):
# getting data
if self._args.calendar_file:
data = CommonReader.get_data_from_file(self._args.calendar_file,
encoding=None)
elif self._args.calendar_url:
data = CommonReader.get_data_from_url(self._args.calendar_url)
# read and go through calendar
cal = Calendar.from_ical(data)
for component in cal.walk():
if component.name == "VCALENDAR":
self.__handle_vcalendar(component)
elif component.name == "VEVENT":
self.__handle_vevent(component)
else:
logging.debug("Not handling component: " + component.name)
def __compute_existing_id_list(self):
"""
Reads the outputfile, looks for :ID: properties and stores them in
self.__existing_ids
"""
assert self.__existing_ids == []
data = CommonReader.get_data_from_file(self.__file_name)
for found_id in re.findall(":ID:(.*)\n.*:END:", data):
found_id = found_id.strip()
if found_id != "":
self.__existing_ids.append(found_id)
logging.debug("found id :ID: %s", found_id)
logging.debug("there are already %d entries", len(self.__existing_ids))
def _main(self):
"""
gets called automatically from Memacs class.
read the lines from phonecalls backup xml file,
parse and write them to org file
"""
self._parse_data(CommonReader.get_data_from_file(self._args.phonelogfile))
def _main(self):
"""
get's automatically called from Memacs class
"""
# getting data
if self._args.file:
data = CommonReader.get_data_from_file(self._args.file)
elif self._args.url:
data = CommonReader.get_data_from_url(self._args.url)
rss = feedparser.parse(data)
logging.info("title: %s", rss['feed']['title'])
logging.info("there are: %d entries", len(rss.entries))
for item in rss.entries:
logging.debug(item)
output, note, properties, tags, timestamp = \
self.__get_item_data(item)
self._writer.write_org_subitem(output=output,
timestamp=timestamp,
note=note,
properties=properties,
tags=tags)