Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
4e064fa7
Commit
4e064fa7
authored
Feb 19, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ReadShiftFromSpreadsheet to use TimeSupport correctly and be more generic
parent
403bfaf5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
dream/plugins/ReadShiftFromSpreadsheet.py
dream/plugins/ReadShiftFromSpreadsheet.py
+9
-6
No files found.
dream/plugins/ReadShiftFromSpreadsheet.py
View file @
4e064fa7
...
...
@@ -14,13 +14,16 @@ class ReadShiftFromSpreadsheet(plugin.InputPreparationPlugin, TimeSupportMixin):
"""
def
preprocess
(
self
,
data
):
self
.
initializeTimeSupport
(
data
)
strptime
=
datetime
.
datetime
.
strptime
# read the current date and define dateFormat from it
try
:
now
=
strptime
(
data
[
'general'
][
'currentDate'
],
'%Y/%m/%d %H:%M'
)
data
[
'general'
][
'dateFormat'
]
=
'%Y/%m/%d %H:%M'
except
ValueError
:
now
=
strptime
(
data
[
'general'
][
'currentDate'
],
'%Y/%m/%d'
)
data
[
'general'
][
'dateFormat'
]
=
'%Y/%m/%d'
self
.
initializeTimeSupport
(
data
)
shift_by_station
=
{}
# XXX machine_shift_spreadsheet should be configuration
for
line
in
data
[
'input'
][
'machine_shift_spreadsheet'
][
1
:]:
...
...
@@ -34,9 +37,9 @@ class ReadShiftFromSpreadsheet(plugin.InputPreparationPlugin, TimeSupportMixin):
if
start_time
<
0
:
start_time
=
0
# sometimes the date may change (e.g. shift from 23:00 to 01:00).
# these would be declared in the date of the start so add a date (
1440
) to the end
# these would be declared in the date of the start so add a date (
self.timeUnitPerDay
) to the end
if
stop_time
<
start_time
:
stop_time
+=
1440
stop_time
+=
self
.
timeUnitPerDay
for
station
in
line
[
1
].
split
(
','
):
station
=
station
.
strip
()
shift_by_station
.
setdefault
(
station
,
[]).
append
(
...
...
@@ -55,9 +58,9 @@ class ReadShiftFromSpreadsheet(plugin.InputPreparationPlugin, TimeSupportMixin):
if
start_time
<
0
:
start_time
=
0
# sometimes the date may change (e.g. shift from 23:00 to 01:00).
# these would be declared in the date of the start so add a date (
1440
) to the end
# these would be declared in the date of the start so add a date (
self.timeUnitPerDay
) to the end
if
stop_time
<
start_time
:
stop_time
+=
1440
stop_time
+=
self
.
timeUnitPerDay
for
station
in
line
[
1
].
split
(
','
):
station
=
station
.
strip
()
shift_by_station
.
setdefault
(
station
,
[]).
append
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment