MCPcopy Create free account
hub / github.com/pyfa-org/Pyfa / Port

Class Port

service/port/port.py:52–344  ·  view source on GitHub ↗

Service which houses all import/export format functions

Source from the content-addressed store, hash-verified

50
51
52class Port:
53 """Service which houses all import/export format functions"""
54 instance = None
55 __tag_replace_flag = True
56
57 @classmethod
58 def getInstance(cls):
59 if cls.instance is None:
60 cls.instance = Port()
61
62 return cls.instance
63
64 @classmethod
65 def set_tag_replace(cls, b):
66 cls.__tag_replace_flag = b
67
68 @classmethod
69 def is_tag_replace(cls):
70 # might there is a person who wants to hold tags.
71 # (item link in EVE client etc. When importing again to EVE)
72 return cls.__tag_replace_flag
73
74 @staticmethod
75 def backupFits(path, progress):
76 pyfalog.debug("Starting backup fits thread.")
77
78 def backupFitsWorkerFunc(path, progress):
79 try:
80 backedUpFits = Port.exportXml(svcFit.getInstance().getAllFits(), progress)
81 if backedUpFits:
82 progress.message = f'writing {path}'
83 backupFile = open(path, "w", encoding="utf-8")
84 backupFile.write(backedUpFits)
85 backupFile.close()
86 except (KeyboardInterrupt, SystemExit):
87 raise
88 except Exception as e:
89 progress.error = f'{e}'
90 finally:
91 progress.current += 1
92 progress.workerWorking = False
93
94 threading.Thread(
95 target=backupFitsWorkerFunc,
96 args=(path, progress)
97 ).start()
98
99 @staticmethod
100 def importFitsThreaded(paths, progress):
101 """
102 :param paths: fits data file path list.
103 :rtype: None
104 """
105 pyfalog.debug("Starting import fits thread.")
106
107 def importFitsFromFileWorkerFunc(paths, progress):
108 Port.importFitFromFiles(paths, progress)
109

Callers 2

importFromClipboardMethod · 0.90
getInstanceMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected