def getObjectsByCollectionId(self, collection_id, logger, log_marker):
     objects = []
     for root_dir_path, _, file_names in os.walk(os.path.join(self.__data_dir_path, "record")):
         for file_name in file_names:
             file_path = os.path.join(root_dir_path, file_name)
             if not file_path.endswith(".xml"):
                 os.rename(file_path, file_path + ".xml")
                 file_path = file_path + ".xml"
             objects.append(self.__map_oai_pmh_record(collection_id=collection_id, file_path=file_path))
     return ImmutableList.copyOf(objects)
示例#2
0
 def _parse_records(self):
     objects_by_id = OrderedDict()
     for root_dir_path, _, file_names in os.walk(os.path.join(self._data_dir_path, 'extracted', self._institution_id, 'record')):
         for file_name in file_names:
             file_path = os.path.join(root_dir_path, file_name)
             if not file_path.endswith('.xml'):
                 os.rename(file_path, file_path + '.xml')
                 file_path = file_path + '.xml'
             record_etree = ElementTree.parse(file_path)
             result = self._parse_record(record_etree)
             if result is None:
                 continue
             object_id, object_ = result
             objects_by_id[object_id] = object_
     return objects_by_id
示例#3
0
 def improve_intent(self, message):
     name = self.config_core.get('listener',
                                 {}).get('wake_word').replace(' ', '-')
     i = 1
     if os.path.isdir(self.settings["sell_path"]):
         onlyfiles = next(os.walk(self.settings["sell_path"]))[2]
         if len(onlyfiles) <= self.settings["improve"]:
             selling = len(onlyfiles)
         else:
             selling = self.settings["improve"]
         self.speak_dialog('improve',
                           data={
                               'name': name,
                               "selling": selling
                           })
         self.log.info("search wake word in: " + self.settings["sell_path"])
         for root, dirs, files in os.walk(self.settings["sell_path"]):
             for f in files:
                 filename = os.path.join(root, f)
                 if filename.endswith('.wav'):
                     if i <= selling:
                         self.log.info("play file")
                         play_wav(filename)
                         sell = self.ask_yesno("ask.sell", data={'i': i})
                         i = i + 1
                         if sell == "yes":
                             if not os.path.isdir(
                                     self.settings["file_path"] + "/" +
                                     name + "/wake-word/" + self.lang[:2] +
                                     "-short/"):
                                 os.makedirs(self.settings["file_path"] +
                                             "/" + name + "/wake-word/" +
                                             self.lang[:2] + "-short/")
                             file = (self.settings["file_path"] + "/" +
                                     name + "/wake-word/" + self.lang[:2] +
                                     "-short/" + name + "-" +
                                     self.lang[:2] + "-" +
                                     str(uuid.uuid1()) + ".wav")
                             os.rename(filename, file)
                             self.log.info("move File: " + file)
                         elif sell == "no":
                             if not os.path.isdir(
                                     self.settings["file_path"] + "/" +
                                     name + "not-/wake-word/" +
                                     self.lang[:2] + "-short-not/"):
                                 os.makedirs(self.settings["file_path"] +
                                             "/" + name +
                                             "not-/wake-word/" +
                                             self.lang[:2] + "-short-not/")
                             file = (self.settings["file_path"] + "/" +
                                     name + "not-wake-word/" +
                                     self.lang[:2] + "-short-not/" + name +
                                     "-" + self.lang[:2] + "-" +
                                     str(uuid.uuid1()) + ".wav")
                             os.rename(filename, file)
                             self.log.info("move File: " + file)
                         else:
                             os.remove(filename)
             else:
                 self.speak_dialog('improve.no.file', data={'name': name})
     else:
         self.speak_dialog('improve.no.file', data={'name': name})
示例#4
0
# Open a File
file = open(file="text.txt", mode='wb', buffering=1)
print("Name of the title: ", file.name)
print("Closed or not: ", file.closed)
print("Opening mode: ", file.mode)
file.write(
    bytes("I am not a psychopath, I am a high functioning sociopath.\n",
          "UTF-8"))
file.close()

file = open(file="text.txt", mode="r", buffering=1)
print("Position: ",
      file.tell())  # Tell the position of the current seeking point.
data = file.read()  # Read all bytes
file.close()
print("The read data is: ", data)
print("Closed or not: ", file.closed)

# Use the OS path library.
os.rename("text.txt", "newText.txt")  # Rename the file name.
os.remove("newText.txt")  # Remove the file with this file name.
os.mkdir("folder", mode=0o777)
os.chdir("folder")
# Changes the current directory with this.
os.mkdir("test")  # Makes folder in folder with name test.

print("The current dir: ", os.getcwd())  # Prints the current directory path.
os.rmdir("folder")
# Removes the directory.
from os.path import expanduser, os
import time, subprocess, wget, os
print('SCRIPT BY ANDREI ZHUK')
time.sleep(1)
print('https://vk.com/andrey47785')
#НЕ ВОЛНУЙТЕСЬ ПО ПОВОДУ ТОГО,ЧТО МОДУЛИ НЕ БУДУТ ИМПОРТИРОВАТСЯ ПОТОМУЧТО ЗА ВАС ЭТО СДЕЛАЕТ И ЗАПАКУЕТ В ПРОГРАММУ МОДУЛИ ПАЙ ИНСТАЛЛ
home = expanduser("~")
time.sleep(1.56)
print('Закачиваю файлы...')
time.sleep(1)
print('.\\WHAIT//.')
s = 'https://www.python.org/ftp/python/3.8.7/python-3.8.7rc1-amd64.exe'
filename = wget.download(s)
os.rename(filename, u'' + os.getcwd() + '/' + filename)
subprocess.call([home + '/Desktop/python-3.9.1-amd64.exe'])
print('OK')
os.remove(home + '/Desktop/python-3.9.1-amd64.exe')
print('DELETED TO INSTALATOR')
time.sleep(3)
print('УДАЛЯЮ СЕБЯ...')
os.remove(home + '/Desktop/installpythonby.exe')