Skip to content

Commit 752840d

Browse files
mgermainMarcCote
authored andcommitted
Forget to uncomment stuff.
1 parent 243560b commit 752840d

File tree

1 file changed

+102
-102
lines changed

1 file changed

+102
-102
lines changed

smartdispatch/smartdispatch.py

Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -3,98 +3,98 @@
33
import os
44
from datetime import datetime
55

6-
#import smartdispatch
7-
#from smartdispatch import utils
6+
import smartdispatch
7+
from smartdispatch import utils
88

99
UID_TAG = "{UID}"
1010

1111

12-
# def generate_name_from_command(command, max_length_arg=None, max_length=None):
13-
# ''' Generates name from a given command.
12+
def generate_name_from_command(command, max_length_arg=None, max_length=None):
13+
''' Generates name from a given command.
1414
15-
# Generate a name by replacing spaces in command with dashes and
16-
# by trimming lengthty (as defined by max_length_arg) arguments.
15+
Generate a name by replacing spaces in command with dashes and
16+
by trimming lengthty (as defined by max_length_arg) arguments.
1717
18-
# Parameters
19-
# ----------
20-
# command : str
21-
# command from which to generate the name
22-
# max_length_arg : int
23-
# arguments longer than this will be trimmed keeping last characters (Default: inf)
24-
# max_length : int
25-
# trim name if longer than this keeping last characters (Default: inf)
18+
Parameters
19+
----------
20+
command : str
21+
command from which to generate the name
22+
max_length_arg : int
23+
arguments longer than this will be trimmed keeping last characters (Default: inf)
24+
max_length : int
25+
trim name if longer than this keeping last characters (Default: inf)
2626
27-
# Returns
28-
# -------
29-
# name : str
30-
# slugified name
31-
# '''
32-
# if max_length_arg is not None:
33-
# max_length_arg = min(-max_length_arg, max_length_arg)
27+
Returns
28+
-------
29+
name : str
30+
slugified name
31+
'''
32+
if max_length_arg is not None:
33+
max_length_arg = min(-max_length_arg, max_length_arg)
3434

35-
# if max_length is not None:
36-
# max_length = min(-max_length, max_length)
35+
if max_length is not None:
36+
max_length = min(-max_length, max_length)
3737

38-
# name = '_'.join([utils.slugify(argvalue)[max_length_arg:] for argvalue in command.split()])
39-
# return name[max_length:]
38+
name = '_'.join([utils.slugify(argvalue)[max_length_arg:] for argvalue in command.split()])
39+
return name[max_length:]
4040

4141

42-
# def generate_name_from_arguments(arguments, max_length_arg=None, max_length=None, prefix=datetime.now().strftime('%Y-%m-%d_%H-%M-%S_')):
43-
# ''' Generates name from given unfolded arguments.
42+
def generate_name_from_arguments(arguments, max_length_arg=None, max_length=None, prefix=datetime.now().strftime('%Y-%m-%d_%H-%M-%S_')):
43+
''' Generates name from given unfolded arguments.
4444
45-
# Generate a name by concatenating the first and last values of every
46-
# unfolded arguments and by trimming lengthty (as defined by max_length_arg)
47-
# arguments.
45+
Generate a name by concatenating the first and last values of every
46+
unfolded arguments and by trimming lengthty (as defined by max_length_arg)
47+
arguments.
4848
49-
# Parameters
50-
# ----------
51-
# arguments : list of list of str
52-
# list of unfolded arguments
53-
# max_length_arg : int
54-
# arguments longer than this will be trimmed keeping last characters (Default: inf)
55-
# max_length : int
56-
# trim name if longer than this keeping last characters (Default: inf)
57-
# prefix : str
58-
# text to preprend to the name (Default: current datetime)
49+
Parameters
50+
----------
51+
arguments : list of list of str
52+
list of unfolded arguments
53+
max_length_arg : int
54+
arguments longer than this will be trimmed keeping last characters (Default: inf)
55+
max_length : int
56+
trim name if longer than this keeping last characters (Default: inf)
57+
prefix : str
58+
text to preprend to the name (Default: current datetime)
5959
60-
# Returns
61-
# -------
62-
# name : str
63-
# slugified name
64-
# '''
65-
# if max_length_arg is not None:
66-
# max_length_arg = min(-max_length_arg, max_length_arg)
60+
Returns
61+
-------
62+
name : str
63+
slugified name
64+
'''
65+
if max_length_arg is not None:
66+
max_length_arg = min(-max_length_arg, max_length_arg)
6767

68-
# if max_length is not None:
69-
# max_length = min(-max_length, max_length)
68+
if max_length is not None:
69+
max_length = min(-max_length, max_length)
7070

71-
# name = []
72-
# for argvalues in arguments:
73-
# argvalues = map(utils.slugify, argvalues)
74-
# name.append(argvalues[0][max_length_arg:])
75-
# if len(argvalues) > 1:
76-
# name[-1] += '-' + argvalues[-1][max_length_arg:]
71+
name = []
72+
for argvalues in arguments:
73+
argvalues = map(utils.slugify, argvalues)
74+
name.append(argvalues[0][max_length_arg:])
75+
if len(argvalues) > 1:
76+
name[-1] += '-' + argvalues[-1][max_length_arg:]
7777

78-
# name = "_".join(name)
78+
name = "_".join(name)
7979

80-
# name = prefix + name[max_length:]
81-
# return name
80+
name = prefix + name[max_length:]
81+
return name
8282

8383

84-
# def get_commands_from_file(fileobj):
85-
# ''' Reads commands from `fileobj`.
84+
def get_commands_from_file(fileobj):
85+
''' Reads commands from `fileobj`.
8686
87-
# Parameters
88-
# ----------
89-
# fileobj : file
90-
# opened file where to read commands from
87+
Parameters
88+
----------
89+
fileobj : file
90+
opened file where to read commands from
9191
92-
# Returns
93-
# -------
94-
# commands : list of str
95-
# commands read from the file
96-
# '''
97-
# return fileobj.read().strip().split('\n')
92+
Returns
93+
-------
94+
commands : list of str
95+
commands read from the file
96+
'''
97+
return fileobj.read().strip().split('\n')
9898

9999

100100
def get_commands_from_arguments(arguments):
@@ -130,48 +130,48 @@ def get_commands_from_arguments(arguments):
130130
return unfolded_commands
131131

132132

133-
# def unfold_argument(argument):
134-
# ''' Unfolds a folded argument into a list of unfolded arguments.
133+
def unfold_argument(argument):
134+
''' Unfolds a folded argument into a list of unfolded arguments.
135135
136-
# An argument can be folded e.g. a list of unfolded arguments separated by spaces.
137-
# An unfolded argument unfolds to itself.
136+
An argument can be folded e.g. a list of unfolded arguments separated by spaces.
137+
An unfolded argument unfolds to itself.
138138
139-
# Parameters
140-
# ----------
141-
# argument : str
142-
# argument to unfold
139+
Parameters
140+
----------
141+
argument : str
142+
argument to unfold
143143
144-
# Returns
145-
# -------
146-
# unfolded_arguments : list of str
147-
# result of the unfolding
144+
Returns
145+
-------
146+
unfolded_arguments : list of str
147+
result of the unfolding
148148
149-
# Complex arguments
150-
# -----------------
151-
# *list (space)*: "item1 item2 ... itemN"
152-
# '''
149+
Complex arguments
150+
-----------------
151+
*list (space)*: "item1 item2 ... itemN"
152+
'''
153153

154-
# # Suppose `argument`is a space separated list
155-
# return argument.split(" ")
154+
# Suppose `argument`is a space separated list
155+
return argument.split(" ")
156156

157157

158-
# def replace_uid_tag(commands):
159-
# return [command.replace("{UID}", utils.generate_uid_from_string(command)) for command in commands]
158+
def replace_uid_tag(commands):
159+
return [command.replace("{UID}", utils.generate_uid_from_string(command)) for command in commands]
160160

161161

162-
# def get_available_queues(cluster_name=utils.detect_cluster()):
163-
# """ Fetches all available queues on the current cluster """
164-
# if cluster_name is None:
165-
# return {}
162+
def get_available_queues(cluster_name=utils.detect_cluster()):
163+
""" Fetches all available queues on the current cluster """
164+
if cluster_name is None:
165+
return {}
166166

167-
# smartdispatch_dir, _ = os.path.split(smartdispatch.__file__)
168-
# config_dir = os.path.join(smartdispatch_dir, 'config')
167+
smartdispatch_dir, _ = os.path.split(smartdispatch.__file__)
168+
config_dir = os.path.join(smartdispatch_dir, 'config')
169169

170-
# config_filename = cluster_name + ".json"
171-
# config_filepath = os.path.join(config_dir, config_filename)
170+
config_filename = cluster_name + ".json"
171+
config_filepath = os.path.join(config_dir, config_filename)
172172

173-
# if not os.path.isfile(config_filepath):
174-
# return {} # Unknown cluster
173+
if not os.path.isfile(config_filepath):
174+
return {} # Unknown cluster
175175

176-
# queues_infos = utils.load_dict_from_json_file(config_filepath)
177-
# return queues_infos
176+
queues_infos = utils.load_dict_from_json_file(config_filepath)
177+
return queues_infos

0 commit comments

Comments
 (0)