Skip to content

Commit 13a11e2

Browse files
committed
black formatting
1 parent 214969e commit 13a11e2

File tree

9 files changed

+295
-134
lines changed

9 files changed

+295
-134
lines changed

components/globals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
DATA_DIR = appdirs.user_data_dir(APP_NAME, APP_AUTHOR)
77
LOG_DIR = appdirs.user_log_dir(APP_NAME, APP_AUTHOR)
8-
CACHE_DIR = appdirs.user_cache_dir(APP_NAME, APP_AUTHOR)
8+
CACHE_DIR = appdirs.user_cache_dir(APP_NAME, APP_AUTHOR)

components/job_queue.py

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class JobState(Enum):
2727
FINISHED = "finished"
2828

2929

30-
class JobData():
30+
class JobData:
31+
3132
def __init__(self, cache=True):
3233
self.MAX_ROWS = 1000
3334

@@ -66,7 +67,7 @@ def cache(self):
6667

6768
location = path.join(self.location, str(self.cache_count))
6869
try:
69-
with open(location, 'wb') as f:
70+
with open(location, "wb") as f:
7071
dump(self.data, f)
7172
self.data = []
7273
self.cache_count += 1
@@ -76,7 +77,8 @@ def cache(self):
7677
def read(self):
7778
return self.JobDataIter(self)
7879

79-
class JobDataIter():
80+
class JobDataIter:
81+
8082
def __init__(self, job_data):
8183
self.job_data = job_data
8284
self.cache_count = 0
@@ -92,7 +94,7 @@ def read_cache_i(self, i):
9294
location = path.join(self.job_data.location, str(i))
9395

9496
try:
95-
with open(location, 'rb') as f:
97+
with open(location, "rb") as f:
9698
self.data = load(f)
9799
self.i = 0
98100
self.cache_count += 1
@@ -111,7 +113,7 @@ def read_row(self):
111113

112114
for key in self.job_data.keys:
113115
if not row.get(key):
114-
row[key] = ''
116+
row[key] = ""
115117

116118
return row
117119

@@ -120,7 +122,9 @@ def clean_up(self):
120122

121123
def __next__(self):
122124
if not self.finished_cache:
123-
if (self.cache_count <= self.job_data.cache_count) and self.job_data.cache_count != 0:
125+
if (
126+
self.cache_count <= self.job_data.cache_count
127+
) and self.job_data.cache_count != 0:
124128
if self.i < len(self.data):
125129
return self.read_row()
126130
else:
@@ -140,11 +144,23 @@ def __next__(self):
140144
raise StopIteration
141145

142146

143-
class Job():
147+
class Job:
144148
error_log = QtCore.pyqtSignal(str)
145149

146-
def __init__(self, outputPath, sourceName, sourceFunction, functionArgs, sourceKeys, append, keyColumn, encoding,
147-
cache, job_update, job_error_log):
150+
def __init__(
151+
self,
152+
outputPath,
153+
sourceName,
154+
sourceFunction,
155+
functionArgs,
156+
sourceKeys,
157+
append,
158+
keyColumn,
159+
encoding,
160+
cache,
161+
job_update,
162+
job_error_log,
163+
):
148164
self.source = eval(f"socialreaper.{sourceName}(**{sourceKeys})")
149165
self.source.api.log_function = self.log
150166
self.log_function = job_error_log
@@ -189,9 +205,16 @@ def inc_data(self):
189205
def end_job(self):
190206
self.state = JobState.SAVING
191207
self.job_update.emit(self)
192-
socialreaper.tools.CSV(self.data.read(), file_name=self.outputPath, flat=False, append=self.append,
193-
key_column=self.keyColumn, encoding=self.encoding, fill_gaps=False,
194-
field_names=sorted(self.data.keys))
208+
socialreaper.tools.CSV(
209+
self.data.read(),
210+
file_name=self.outputPath,
211+
flat=False,
212+
append=self.append,
213+
key_column=self.keyColumn,
214+
encoding=self.encoding,
215+
fill_gaps=False,
216+
field_names=sorted(self.data.keys),
217+
)
195218
self.state = JobState.FINISHED
196219
self.job_update.emit(self)
197220
return False
@@ -214,7 +237,7 @@ def pickle(self):
214237
if not path.exists(dir):
215238
makedirs(dir)
216239

217-
with open(f"{dir}/out.pickle", 'wb') as f:
240+
with open(f"{dir}/out.pickle", "wb") as f:
218241
dump(self, f)
219242

220243

@@ -289,7 +312,14 @@ def add_jobs(self, details):
289312
try:
290313
for params in details:
291314
self.jobs.append(
292-
Job(*params, self.window.encoding, self.window.cache_enabled, self.job_update, self.job_error_log))
315+
Job(
316+
*params,
317+
self.window.encoding,
318+
self.window.cache_enabled,
319+
self.job_update,
320+
self.job_error_log,
321+
)
322+
)
293323
except Exception as e:
294324
self.job_error_log.emit(format_exc())
295325

@@ -329,7 +359,6 @@ def inc_job(self):
329359
self.currentJobState = None
330360
self.queue_update.emit(self.jobs)
331361

332-
333362
else:
334363
self.state = QueueState.STOPPED
335364
self.queue_update.emit(self.jobs)

components/keys.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
class KeyLine(QtWidgets.QLineEdit):
8+
89
def __init__(self, name, key, sources, save):
910
super().__init__()
1011

@@ -24,6 +25,7 @@ def edit_key(self, text):
2425

2526

2627
class KeyPage(QtWidgets.QWidget):
28+
2729
def __init__(self, scrollWidget, data_dir, parent=None):
2830
super().__init__(parent=parent)
2931

@@ -41,14 +43,14 @@ def __init__(self, scrollWidget, data_dir, parent=None):
4143

4244
def read_keys(self):
4345
try:
44-
with open(self.location, 'r') as f:
46+
with open(self.location, "r") as f:
4547
data = json.load(f)
4648
self.sources = data
4749
except (FileNotFoundError, json.decoder.JSONDecodeError):
4850
pass
4951

5052
def write_keys(self):
51-
with open(self.location, 'w') as f:
53+
with open(self.location, "w") as f:
5254
json.dump(self.sources, f)
5355

5456
def add_source(self, name, keys):

0 commit comments

Comments
 (0)