Skip to content

Commit 6b921c1

Browse files
authored
Merge pull request fmauch#4 from sjahr/master
Add python3 compatibility
2 parents 86a883b + 0b07fc3 commit 6b921c1

File tree

5 files changed

+23
-17
lines changed

5 files changed

+23
-17
lines changed

package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<exec_depend>python-yaml</exec_depend>
5353
<exec_depend>rospy</exec_depend>
5454
<exec_depend>tmux</exec_depend>
55+
<exec_depend>future</exec_depend>
5556

5657
<!-- The export tag contains other, unspecified, tags -->
5758
<export>

src/catmux/__init__.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# -- END LICENSE BLOCK ------------------------------------------------
2020

2121
"""Loads all modules from other files"""
22+
from __future__ import absolute_import
2223

23-
from window import Window
24-
from session import Session
24+
from catmux.window import Window
25+
from catmux.session import Session

src/catmux/session.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
# -- END LICENSE BLOCK ------------------------------------------------
2020

2121
"""Contains everything around the config file"""
22-
from __future__ import print_function
22+
from __future__ import print_function, absolute_import
2323

2424
import re
2525
import yaml
2626

27-
from window import Window
28-
import tmux_wrapper as tmux
27+
from catmux.window import Window
28+
import catmux.tmux_wrapper as tmux
2929

3030

3131
def check_boolean_field(boolean):
@@ -52,7 +52,7 @@ def init_from_filepath(self, filepath):
5252
"""Initializes the data from a file read from filepath."""
5353

5454
try:
55-
self.__yaml_data = yaml.load(file(filepath, 'r'))
55+
self.__yaml_data = yaml.load(open(filepath, 'r'))
5656
except yaml.YAMLError as exc:
5757
print('Error while loading config file: %s', exc)
5858
print('Loaded file was: %s', filepath)
@@ -114,11 +114,11 @@ def _parse_parameters(self):
114114

115115
print('Parameters found in session config:')
116116
print(' - ' + '\n - '.join('{} = {}'.format(key, value)
117-
for key, value in self._parameters.items()))
117+
for key, value in list(self._parameters.items())))
118118
if self._runtime_params:
119119
print('Parameters found during runtime (overwrites):')
120120
print(' - ' + '\n - '.join('{} = {}'.format(key, value)
121-
for key, value in self._runtime_params.items()))
121+
for key, value in list(self._runtime_params.items())))
122122
# Overwrite parameters given from command line
123123
self._parameters.update(self._runtime_params)
124124

@@ -127,13 +127,13 @@ def _parse_parameters(self):
127127

128128
def _replace_parameters(self, data):
129129
if isinstance(data, dict):
130-
for key, value in data.items():
130+
for key, value in list(data.items()):
131131
data[key] = self._replace_parameters(value)
132132
elif isinstance(data, list):
133133
for index, item in enumerate(data):
134134
data[index] = self._replace_parameters(item)
135135
elif isinstance(data, str):
136-
for key, value in self._parameters.items():
136+
for key, value in list(self._parameters.items()):
137137
# print('-\nValue {}: {}\n='.format(value, type(data)))
138138
# if isinstance(value, str):
139139
# print('replacing {} in {}'.format(key, data))

src/catmux/split.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
# -- END LICENSE BLOCK ------------------------------------------------
2020

2121
"""A split in a tmux session"""
22-
from __future__ import print_function
22+
from __future__ import print_function, absolute_import
2323

24-
import tmux_wrapper as tmux
24+
from future.utils import iteritems
25+
26+
import catmux.tmux_wrapper as tmux
2527

2628

2729
class Split(object):
@@ -32,7 +34,7 @@ def __init__(self, **kwargs):
3234
"""TODO: to be defined1. """
3335

3436
if kwargs is not None:
35-
for key, value in kwargs.iteritems():
37+
for (key, value) in iteritems(kwargs):
3638
setattr(self, key, value)
3739

3840
def debug(self, name='', prefix=''):

src/catmux/window.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919
# -- END LICENSE BLOCK ------------------------------------------------
2020

2121
"""Contains the Window object"""
22-
from __future__ import print_function
22+
from __future__ import print_function, absolute_import
23+
24+
from future.utils import iteritems
2325

2426
import time
2527

26-
import tmux_wrapper as tmux
27-
from split import Split
28+
import catmux.tmux_wrapper as tmux
29+
from catmux.split import Split
2830

2931

3032
class Window(object):
@@ -45,7 +47,7 @@ def __init__(self, **kwargs):
4547
self.splits.append(Split(**split_data))
4648

4749
if kwargs is not None:
48-
for key, value in kwargs.iteritems():
50+
for (key, value) in iteritems (kwargs):
4951
setattr(self, key, value)
5052

5153

0 commit comments

Comments
 (0)