EmbASP-Python
input_program.py
1 class InputProgram(object):
2  """Represents a generic option."""
3 
4  def __init__(self):
5  """Creates new programs setting space as default separator."""
6  self._programs = "" # Where programs data is stored
7  self.__files_paths = list() # Where associated files are stored
8  self._separator = " " # Used as separator for programs
9 
10  def add_object_input(self, input_obj):
11  raise "Functionality not implemented"
12 
13  def add_objects_input(self, input_objs):
14  for inputObj in input_objs:
15  self.add_object_input(inputObj)
16 
17  def add_files_path(self, file_path):
18  """Add a new file path into __files_paths.
19 
20  The parameter file_path represents a new file path.
21  """
22  self.__files_paths.append(file_path)
23 
24  def add_program(self, new_instruction):
25  """Adds a new instruction directly into _programs.
26 
27  The parameter new_instruction represents a new program
28  instruction.
29  """
30  if self._programs is None:
31  self._programs = new_instruction
32  else:
33  self._programs += self._separator + new_instruction
34 
35  def clear_files_paths(self):
36  """After this method, __files_paths will be empty."""
37  del self.__files_paths[:]
38 
39  def clear_programs(self):
40  """After this method, _programs will be empty."""
41  self._programs = None
42 
43  def clear_all(self):
44  """After this method, both __files_paths and _programs will be
45  empty."""
46  self.clear_files_paths()
47  self.clear_programs()
48 
49  def get_files_paths(self):
50  """Returns the __files_paths list."""
51  return self.__files_paths
52 
53  def get_programs(self):
54  """Returns data stored in _programs."""
55  return self._programs
56 
57  def get_separator(self):
58  """Returns the _separator character."""
59  return self._separator
60 
62  """Returns string concatenating files paths."""
63  to_return = ""
64  for paths in self.__files_paths:
65  if len(paths) != 0:
66  to_return += paths + " "
67  return to_return
68 
69  def set_programs(self, programs):
70  """Sets _programs value to the given one.
71 
72  The parameter programs represents a new value.
73  """
74  self._programs = programs
75 
76  def set_separator(self, separator):
77  """Set programs separator to the given one.
78 
79  The parameter separator is used as new separator.
80  """
81  self._separator = separator
base.input_program.InputProgram.get_string_of_files_paths
def get_string_of_files_paths(self)
Definition: input_program.py:61
base.input_program.InputProgram.clear_programs
def clear_programs(self)
Definition: input_program.py:39
base.input_program.InputProgram.add_program
def add_program(self, new_instruction)
Definition: input_program.py:24
base.input_program.InputProgram
Definition: input_program.py:1
base.input_program.InputProgram._programs
_programs
Definition: input_program.py:6
base.input_program.InputProgram.get_files_paths
def get_files_paths(self)
Definition: input_program.py:49
base.input_program.InputProgram.clear_files_paths
def clear_files_paths(self)
Definition: input_program.py:35
base.input_program.InputProgram.get_programs
def get_programs(self)
Definition: input_program.py:53
base.input_program.InputProgram.add_object_input
def add_object_input(self, input_obj)
Definition: input_program.py:10
base.input_program.InputProgram.__files_paths
__files_paths
Definition: input_program.py:7
base.input_program.InputProgram.add_files_path
def add_files_path(self, file_path)
Definition: input_program.py:17
base.input_program.InputProgram.clear_all
def clear_all(self)
Definition: input_program.py:43
base.input_program.InputProgram._separator
_separator
Definition: input_program.py:8
base.input_program.InputProgram.set_separator
def set_separator(self, separator)
Definition: input_program.py:76
base.input_program.InputProgram.get_separator
def get_separator(self)
Definition: input_program.py:57
base.input_program.InputProgram.__init__
def __init__(self)
Definition: input_program.py:4
base.input_program.InputProgram.set_programs
def set_programs(self, programs)
Definition: input_program.py:69