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
25517689
Commit
25517689
authored
Feb 18, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shift spreadsheet to be able to read starting time
parent
cd52f5aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
dream/plugins/ReadShiftFromSpreadsheet.py
dream/plugins/ReadShiftFromSpreadsheet.py
+16
-0
No files found.
dream/plugins/ReadShiftFromSpreadsheet.py
View file @
25517689
...
@@ -16,6 +16,10 @@ class ReadShiftFromSpreadsheet(plugin.InputPreparationPlugin, TimeSupportMixin):
...
@@ -16,6 +16,10 @@ class ReadShiftFromSpreadsheet(plugin.InputPreparationPlugin, TimeSupportMixin):
def
preprocess
(
self
,
data
):
def
preprocess
(
self
,
data
):
self
.
initializeTimeSupport
(
data
)
self
.
initializeTimeSupport
(
data
)
strptime
=
datetime
.
datetime
.
strptime
strptime
=
datetime
.
datetime
.
strptime
try
:
now
=
strptime
(
data
[
'general'
][
'currentDate'
],
'%Y/%m/%d %H:%M'
)
except
ValueError
:
now
=
strptime
(
data
[
'general'
][
'currentDate'
],
'%Y/%m/%d'
)
shift_by_station
=
{}
shift_by_station
=
{}
# XXX machine_shift_spreadsheet should be configuration
# XXX machine_shift_spreadsheet should be configuration
...
@@ -23,6 +27,12 @@ class ReadShiftFromSpreadsheet(plugin.InputPreparationPlugin, TimeSupportMixin):
...
@@ -23,6 +27,12 @@ class ReadShiftFromSpreadsheet(plugin.InputPreparationPlugin, TimeSupportMixin):
if
line
[
1
]:
if
line
[
1
]:
start_time
=
self
.
convertToSimulationTime
(
strptime
(
"%s %s"
%
(
line
[
0
],
line
[
2
]),
'%Y/%m/%d %H:%M'
))
start_time
=
self
.
convertToSimulationTime
(
strptime
(
"%s %s"
%
(
line
[
0
],
line
[
2
]),
'%Y/%m/%d %H:%M'
))
stop_time
=
self
.
convertToSimulationTime
(
strptime
(
"%s %s"
%
(
line
[
0
],
line
[
3
]),
'%Y/%m/%d %H:%M'
))
stop_time
=
self
.
convertToSimulationTime
(
strptime
(
"%s %s"
%
(
line
[
0
],
line
[
3
]),
'%Y/%m/%d %H:%M'
))
# if the end of shift is before now we do not need this shif in the simulation
if
stop_time
<=
0
:
continue
# if the start of the shift is before now, set the start to 0
if
start_time
<
0
:
start_time
=
0
for
station
in
line
[
1
].
split
(
','
):
for
station
in
line
[
1
].
split
(
','
):
station
=
station
.
strip
()
station
=
station
.
strip
()
shift_by_station
.
setdefault
(
station
,
[]).
append
(
shift_by_station
.
setdefault
(
station
,
[]).
append
(
...
@@ -34,6 +44,12 @@ class ReadShiftFromSpreadsheet(plugin.InputPreparationPlugin, TimeSupportMixin):
...
@@ -34,6 +44,12 @@ class ReadShiftFromSpreadsheet(plugin.InputPreparationPlugin, TimeSupportMixin):
if
line
[
1
]:
if
line
[
1
]:
start_time
=
self
.
convertToSimulationTime
(
strptime
(
"%s %s"
%
(
line
[
0
],
line
[
2
]),
'%Y/%m/%d %H:%M'
))
start_time
=
self
.
convertToSimulationTime
(
strptime
(
"%s %s"
%
(
line
[
0
],
line
[
2
]),
'%Y/%m/%d %H:%M'
))
stop_time
=
self
.
convertToSimulationTime
(
strptime
(
"%s %s"
%
(
line
[
0
],
line
[
3
]),
'%Y/%m/%d %H:%M'
))
stop_time
=
self
.
convertToSimulationTime
(
strptime
(
"%s %s"
%
(
line
[
0
],
line
[
3
]),
'%Y/%m/%d %H:%M'
))
# if the end of shift is before now we do not need this shif in the simulation
if
stop_time
<=
0
:
continue
# if the start of the shift is before now, set the start to 0
if
start_time
<
0
:
start_time
=
0
for
station
in
line
[
1
].
split
(
','
):
for
station
in
line
[
1
].
split
(
','
):
station
=
station
.
strip
()
station
=
station
.
strip
()
shift_by_station
.
setdefault
(
station
,
[]).
append
(
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