Skip to content

Commit b112316

Browse files
author
Alex Meadows
committed
process_tracker_python-155 Clean up code quality issues
Cleaned up the easier code quality issues to make the code easier to read and work with.
1 parent 94c7ff5 commit b112316

File tree

3 files changed

+25
-37
lines changed

3 files changed

+25
-37
lines changed

process_tracker/extract_tracker.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@
2222
ExtractSourceObject,
2323
ExtractStatus,
2424
)
25-
from process_tracker.models.source import (
26-
Source,
27-
SourceLocation,
28-
SourceObjectAttribute,
29-
SourceObjectLocation,
30-
)
25+
from process_tracker.models.source import SourceLocation, SourceObjectLocation
3126
from process_tracker.models.source import DatasetType
3227

3328

@@ -454,9 +449,9 @@ def get_dataset_types(self):
454449
"""
455450
dataset_types = list()
456451

457-
for type in self.extract.extract_dataset_types:
452+
for data_type in self.extract.extract_dataset_types:
458453
dataset_type = self.data_store.get_or_create_item(
459-
model=DatasetType, dataset_type_id=type.dataset_type_id
454+
model=DatasetType, dataset_type_id=data_type.dataset_type_id
460455
)
461456
dataset_types.append(dataset_type)
462457

@@ -529,22 +524,22 @@ def register_extract_sources(self, sources=None, source_objects=None):
529524

530525
if source_objects is not None:
531526

532-
for object in source_objects:
527+
for src_object in source_objects:
533528
self.logger.debug(
534529
"Associating extract %s to source %s."
535-
% (self.extract.extract_id, object.source_object_id)
530+
% (self.extract.extract_id, src_object.source_object_id)
536531
)
537532

538533
source_object = self.data_store.get_or_create_item(
539534
model=ExtractSourceObject,
540535
extract_id=self.extract.extract_id,
541-
source_object_id=object.source_object_id,
536+
source_object_id=src_object.source_object_id,
542537
)
543538
source_list.append(source_object)
544539

545540
self.data_store.get_or_create_item(
546541
SourceObjectLocation,
547-
source_object_id=object.source_object_id,
542+
source_object_id=src_object.source_object_id,
548543
location_id=self.extract.extract_location_id,
549544
)
550545

process_tracker/models/schedule.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,9 @@
22
# Models for Schedule entities
33

44

5-
from sqlalchemy import (
6-
Boolean,
7-
Column,
8-
DateTime,
9-
ForeignKey,
10-
Integer,
11-
Sequence,
12-
String,
13-
UniqueConstraint,
14-
)
15-
from sqlalchemy.orm import relationship
5+
from sqlalchemy import Column, Integer, Sequence, String
166

17-
from process_tracker.models.model_base import default_date, Base
7+
from process_tracker.models.model_base import Base
188

199

2010
class ScheduleFrequency(Base):

process_tracker/process_tracker.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ def __init__(
9191
:type source_objects: dict of lists
9292
:param target_objects: Finer grained list of targets, including target objects (i.e. tables). Optional.
9393
:type target_objects: dict of lists
94-
:param source_object_attributes: Even finer grained list of sources, including source objects (i.e. tables) and their attributes. Optional.
94+
:param source_object_attributes: Even finer grained list of sources, including source objects (i.e. tables) and
95+
their attributes. Optional.
9596
:type source_object_attributes: dict of lists
96-
:param target_object_attributes: Even finer grained list of targets, including target objects (i.e. tables) and their attributes. Optional.
97+
:param target_object_attributes: Even finer grained list of targets, including target objects (i.e. tables) and
98+
their attributes. Optional.
9799
:type target_object_attributes: dict of lists
98100
:param config_location: Location where Process Tracker configuration file is. If not set, will use local home
99101
directory.
@@ -102,7 +104,8 @@ def __init__(
102104
:type dataset_types: list
103105
:param schedule_frequency: The general scheduling frequency for the process (i.e. hourly)
104106
:type schedule_frequency: string
105-
:param process_run_id: If trying to access an already running process, provide the process run's id. Object will be built for that specific process run.
107+
:param process_run_id: If trying to access an already running process, provide the process run's id.
108+
Object will be built for that specific process run.
106109
:type process_run_id: int
107110
"""
108111
self.config_location = config_location
@@ -393,9 +396,9 @@ def determine_process_sources(self, process_run_id):
393396

394397
if objects.count() >= 1:
395398
self.logger.info("Objects were not empty.")
396-
for object in objects:
397-
self.logger.debug("Adding object %s " % object)
398-
source_list.append(object)
399+
for obj in objects:
400+
self.logger.debug("Adding object %s " % obj)
401+
source_list.append(obj)
399402

400403
return source_list
401404

@@ -678,15 +681,15 @@ def find_process_filters(self, process):
678681
)
679682
)
680683

681-
for filter in filters:
684+
for data_filter in filters:
682685
filter_list.append(
683686
{
684-
"source_name": filter.source_name,
685-
"source_object_name": filter.source_object_name,
686-
"source_object_attribute_name": filter.source_object_attribute_name,
687-
"filter_type_code": filter.filter_type_code,
688-
"filter_value_numeric": filter.filter_value_numeric,
689-
"filter_value_string": filter.filter_value_string,
687+
"source_name": data_filter.source_name,
688+
"source_object_name": data_filter.source_object_name,
689+
"source_object_attribute_name": data_filter.source_object_attribute_name,
690+
"filter_type_code": data_filter.filter_type_code,
691+
"filter_value_numeric": data_filter.filter_value_numeric,
692+
"filter_value_string": data_filter.filter_value_string,
690693
}
691694
)
692695

0 commit comments

Comments
 (0)