def get_hierarchy_latex(self):
     """
     creates a hierarchy of files and subdirectories within the main directory
     and writes it into a latex compatible string
     ###
     RETURNS (string)
     """
     indent = "    "
     main_string = ""
     main_string += "\\setstretch {0.74}%\n"
     main_string += self.name+"\n"
     main_string += "\\begin{itemize}\n"
     for subdir in self.subdirs:
         # going for he first layer of subdirectories
         main_string += "\item[$\\blacktriangleright$] "+jtstr.latex_compatible(subdir.get_name())+"\n"
         main_string += indent+"\\begin{itemize}\n"
         if not(subdir.subdirs == []):
             for subdir2 in subdir.subdirs:
                 main_string += indent+"\item[$\\blacktriangleright$] "+jtstr.latex_compatible(subdir2.get_name())+"\n"
                 # going for the second layer
                 main_string += indent+indent+"\\begin{itemize}\n"
                 if not(subdir2.subdirs == []):
                     for subdir3 in subdir2.subdirs:
                         main_string += indent+indent+"\item[$\\blacktriangleright$] "+jtstr.latex_compatible(subdir3.get_name())+"\n"
                         # going for the third layer
                         main_string += indent+indent+indent+"\\begin{itemize}\n"
                         if not(subdir3.subdirs == []):
                             for subdir4 in subdir3.subdirs:
                                 main_string += indent+indent+indent+"\item[$\\blacktriangleright$] "+jtstr.latex_compatible(subdir4.get_name())+"\n"
                         for file4 in subdir3.files:
                             main_string += indent+indent+indent+"\item[$\\vartriangleright$] "+jtstr.latex_compatible(file4)+"\n"
                         main_string += indent+indent+indent+"\end{itemize}\n"
                 for file3 in subdir2.files:
                     main_string += indent+indent+"\item[$\\vartriangleright$] "+jtstr.latex_compatible(file3)+"\n"
                 main_string += indent+indent+"\end{itemize}\n"
         for file2 in subdir.files:
             main_string += indent+"\item[$\\vartriangleright$] "+jtstr.latex_compatible(file2)+"\n"
         main_string += indent+"\end{itemize}\n"
     for file in self.files:
         main_string += "\item[$\\vartriangleright$] "+jtstr.latex_compatible(file)+"\n"
     main_string += "\end{itemize}\n"
     "\\setstretch {1.433}%\n"
     # returning the whole string
     return main_string
Exemple #2
0
    def add_arguments(self, arg):
        """
        has to be called whenever th script is used from within the JTShell 
        environment, adds the parameters, which would normally be provided directly
        by the system variable.
        ###
        arg - (string) the string passed onto the shell
        ###
        RETURNS (void)
        """
        # dividing the given string into the the list of arguments and the given
        # values of these parameters, by breaking the string by every appearance
        # of the '-' key and making an exception at the "" separation

        # the toggle wether inside an separated string
        in_separation = False
        # the temporary key, value pair of the current argument
        temp_argument_tuples = []
        # the actual temporary string
        temp_string = ""
        # first step: dividing the string into strings of key/value pairs with whitespaces
        for character in arg:
            # toggeling the separation condition
            if character == '"':
                if in_separation:
                    in_separation = False
                else:
                    in_separation = True
            # breaking the temporary string in case the keycharacter "-" appears
            if character == "-" and not (in_separation):
                temp_argument_tuples.append(temp_string)
                temp_string = ""
            # adding the character to the temporary string
            temp_string += character
        temp_argument_tuples.append(temp_string)
        temp_argument_tuples.remove("")

        # second step: itering through the tempory list and then appending the
        # argiuments to the arguments dictionary of the class
        for string in temp_argument_tuples:
            temp_string = jtstr.divide_by_custom(string, " ")[0]
            if '"' in string:
                self.args[temp_string] = string.replace(temp_string + " ", "").replace('"', "")
            else:
                self.args[temp_string] = string.replace(temp_string + " ", "")
 def __init__(self, value):
     # Initializing the super constructor
     DataTypeArray.__init__(self)
     # checking the type of the parameter
     
     # value is string
     if type(value) is str:
         temp_list = JTString.divide_by_whitespace(value)
         for substring in temp_list:
             self.valuearray.append(Binary(substring))
         for subbinary in self.valuearray:
             self.decimalarray.append(subbinary.get_decimalvalue())
             self.stringarray.append(subbinary.get_string())
     
     # value is list
     elif type(value) is list:
         # list consists of integers
         if type(value[0]) is int:
             for subvalue in value:
                 self.decimalarray.append(subvalue)
                 self.valuearray.append(Binary(subvalue))
             for subbinary in self.valuearray:
                 self.stringarray.append(subbinary.get_string())
         # list consists of DataTypes
         elif isinstance(value[0], DataType):
             for datatype in value:
                 self.decimalarray.append(datatype.get_decimalvalue())
             for integer in self.decimalarray:
                 self.valuearray.append(Binary(integer))
             for subvalue in self.valuearray:
                 self.stringarray.append(subvalue.get_string())
     
     # value is DataType Array
     elif isinstance(value, DataTypeArray):
         self.decimalarray = value.decimalarray
         for integer in self.decimalarray:
             self.valuearray.append(Binary(integer))
         for subvalue in self.valuearray:
             self.stringarray.append(subvalue.get_string())
             
     # creating the stringvalue attribute
     self._calcstringvalue()        
 def __calcbinary(self, decimal):
     """
     converts the given integer "decimal" into a string, inheriting
     binary type data
     ###
     decimal - (int) the decimal value
     ###
     RETURNS (string)
     """
     new_binary = ""
     leftover = 0
     temp_value = decimal
     while temp_value != 0:
         # updating the temporary data
         leftover = temp_value % 2
         temp_value = JTString.round_down(temp_value / 2)
         # creating the binary digits
         new_binary = str(leftover) + new_binary
     # returning the new binary value
     return new_binary
 def __calchexa(self, decimal):
     """
     converts the given integer "decimal" into a string, inheriting
     hecadecimal type data
     ###
     decimal - (int) the decimal value
     ###
     RETURNS (string)
     """
     new_hexa = ""
     leftover = 0
     temp_value = decimal
     while temp_value != 0:
         # updating the temporary data
         leftover = temp_value % 16
         temp_value = JTString.round_down(temp_value / 16)
         # creating the hexadecimal digits
         new_hexa = Hexadecimal.d_to_h[leftover] + new_hexa
     # returning the new hexadecimal value
     return new_hexa