コード例 #1
0
    def __init__(self, root):
        self.root = root
        dirname = os.path.dirname(__file__)

        # ===================================
        self.imagelogopath = PathSteel(dir_path=dirname,
                                       Is_Directory_Path_To_SubFolder=True,
                                       FileName="logo.png",
                                       subfolder="img")
        self.pathconfig1 = PathSteel(dir_path=dirname,
                                     Is_Directory_Path_To_SubFolder=True,
                                     FileName="hrdata_modified.csv",
                                     subfolder="config")
        self.pathconfig = resource_path_is_from_pyinstall_and_dev(
            self.pathconfig1.refpath())

        pathconfigexell = PathSteel(dir_path=dirname,
                                    Is_Directory_Path_To_SubFolder=True,
                                    FileName="conf_ex.xlsx",
                                    subfolder="config")
        self.pathconfigexell = resource_path_is_from_pyinstall_and_dev(
            pathconfigexell.refpath())

        self.imagelogo = ImageTk.PhotoImage(file=self.imagelogopath.refpath())

        # path to config of excel to copy
        self.pathconfigexcelcopy = resource_path_is_from_pyinstall_and_dev(
            PathSteel(dir_path=dirname,
                      Is_Directory_Path_To_SubFolder=True,
                      FileName="config_hm.xlsx",
                      subfolder="config").refpath())

        self.pathtokey = resource_path_is_from_pyinstall_and_dev(
            refullpath(dirpath=dirname,
                       filename="key.key",
                       folderchild="config"))
        self.pathtovaluecsv_key = resource_path_is_from_pyinstall_and_dev(
            refullpath(dirpath=dirname,
                       folderchild="config",
                       filename="fn.csv"))
        self.ser_key = resource_path_is_from_pyinstall_and_dev(
            refullpath(dirpath=dirname,
                       folderchild="config",
                       filename="seri.key"))
        self.valueser_key = resource_path_is_from_pyinstall_and_dev(
            refullpath(dirpath=dirname,
                       folderchild="config",
                       filename="ser.csv"))

        k = key_license(pathtokey=self.pathtokey,
                        pathtoserial_key=self.ser_key,
                        root=self.root,
                        pathtovaluecsv_key=self.pathtovaluecsv_key,
                        pathvalueser_key=self.valueser_key)
        print("returnk", k)
        # account authentication
        """
コード例 #2
0
    def __init__(self, parent, controller):
        self.parent = parent
        self.controller = controller
        tk.Frame.__init__(self, parent)

        self.inyname = Label(self,
                             text="INPUT YOUR NAME",
                             width=17,
                             bg="SteelBlue2",
                             fg="black")

        # create full path
        self.pathcre = r"C:\NLT"
        Path(self.pathcre).mkdir(parents=True, exist_ok=True)
        # return path full
        ps = PathSteel(dir_path=self.pathcre, FileName="nhuan.csv")
        self.pathf = ps.refpath()
        rinput = rcsv(pathtor=self.pathf, indexarrtoget=[0])
        row = rinput.Rerowbyindxaindexarr()
        row = list(set(row))
        self.inynamein = ttk.Combobox(self, values=row)

        self.button = tk.Button(self,
                                text="Next",
                                command=lambda: self.checkinputyourname())
        self.inyname.pack()
        self.inynamein.pack()
        self.button.pack()
コード例 #3
0
def getdirpathfromorigin(output1):
    # Get path full
    global pathinout
    pathinout = getpathfromtk(output1)
    filename = ExtractFileNameFromPath(pathinout)
    filename1 = getfilenamewoexten(filename)
    # get dirpath from full path
    dn = getdirpath(pathinout)

    ps = PathSteel(dir_path=dn, FileName=filename1 + ".csv")
    pathf = ps.refpath()
    return pathf
コード例 #4
0
    def __init__(self,
                 pathfolder=None,
                 fileparent="WHITEX - TONG HOP NGAN SACH.xlsx",
                 filekid="AZB-INPUT.xlsx",
                 subfolderinput="0.input",
                 subfolderoutput="1.output",
                 kipnamesheet=[
                     "AZB-20", "AZB-40", "AZB-50", "AZB-60", "AZB-70", "AZB-80"
                 ],
                 runforexcel="both"):
        self.fileparent = fileparent
        self.pathfolder = pathfolder
        self.filekid = filekid
        self.subfolderinput = subfolderinput
        self.subfolderoutput = subfolderoutput
        self.runforexcel = runforexcel
        self.kipnamesheet = kipnamesheet

        self.ps = PathSteel(dir_path=self.pathfolder,
                            Is_Directory_Path_To_SubFolder=True,
                            subfolder=self.subfolderinput,
                            FileName=self.filekid)
        # return file kid
        self.pathkid = self.ps.refpath()
        # return fileparent
        self.ps.subfolder = self.subfolderoutput
        self.ps.FileName = self.fileparent
        self.pathparent = self.ps.refpath()

        self.namesheet = [
            "AZB-10", "AZB-20", "AZB-30", "AZB-40", "AZB-50", "AZB-60",
            "AZB-70", "AZB-80"
        ]
        #set keysheet
        self.keysheet = {self.namesheet[0]:[41,3,18,None,41,3,18,None],\
                        self.namesheet[1]:[41,3,18,None,41,3,18,None],\
                        self.namesheet[2]:[6,4,19,None,6,4,19,None],\
                        self.namesheet[3]:[41,3,18,None,41,3,18,None],\
                        self.namesheet[4]:[41,3,18,None,41,3,18,None],\
                        self.namesheet[5]:[41,3,18,None,41,3,18,None],\
                        self.namesheet[6]:[41,3,18,None,41,3,18,None],\
                        self.namesheet[7]:[41,3,18,None,41,3,18,None]}
コード例 #5
0
    def synserverfileexc(self, pathtemp, indexcol=None):
        filenametemp = ExtractFileNameFromPath(path=pathtemp)

        dirname = abspath("")
        fullname = PathFromFileNameAndDirpath(dir_path=dirname,
                                              filename=filenametemp)
        ########################################
        pathfulloutput = getpathfromtk(output1)
        filename = ExtractFileNameFromPath(pathfulloutput)
        dbk = nmgui(tktk=self.master).returndirpath(
            getfilenamewoexten(filename))
        ########################################
        #create diff forder for diff file
        dirpathdiff = nmgui(tktk=self.master).returndirpath("diff_history")
        inynameing1 = inynameing.replace(" ", " ")
        pathdiff = PathFromFileNameAndDirpath(dir_path = dirpathdiff,
                                            filename = dt_string_sr +\
                                                 "_" + inynameing1 +\
                                                      "_" + filename)

        ps = PathSteel(dir_path =dbk,
                        FileName = dt_string_sr +\
                                "_" + inynameing1 +\
                                     "_" + filename)
        dbk_fullpath = ps.refpath()

        #get path to orginal location with file name diff

        comparetwofile1 = comparetwofile(
            path_OLD=pathtemp,
            path_NEW=fullname,
            index_col=None,
            usernamein=inynameing1,
            pathtcsvtosavedata=getdirpathfromorigin(output1),
            difpathtobk=dbk_fullpath,
            pathtorgindiff=pathdiff,
            dt=dt_string)
        comparetwofile1.excel_diff()
コード例 #6
0
def CreateFileExcel(pathin,pathout):
    #filename = "Config_Setting.csv"

    pathconf = PathSteel(dir_path =pathin,
                     FileName = "Config_Setting.csv")\
                    .refpath()

    #fullpath = os.path.join(pathin,filename)

    # get path store data to handling
    Right_Genneral_All_path = PathFromFileNameAndDirpath(dir_path =pathin,
                                                         filename ="Right_Genneral_All.csv"
                                                         )
                                    
    Left_Genneral_All_path = PathFromFileNameAndDirpath(dir_path =pathin,
                                                         filename ="Left_Genneral_All.csv"
                                                         )

    # key value 
    keyvalue = ["ValueGeneral", 
                "Columnmove",
                "LocationCellForMoveColumn",
                "GenneralColumnNotChange",
                "GeneralConcernRaffter",
                "Genneral_Select",
                "LocationOfRowLeft",
                "LocationOfRowRight",
                "ExcelCellForMoveColumnRight",
                "LocationOfPurlin",
                "startrow",
                ]
                
    #location in conf
    locvalue = [12,16,17,19,20,21,23,24,25,26,30]

    credict_c = credict(KeyValues = keyvalue, 
                        LocConf = locvalue,
                        Config_Setting_Path = pathconf)
    credict_list = credict_c.Dictfromkeyandvalueconf()

    # create arr from keyvalue  
    valgen = credict_list.get("ValueGeneral", "")
    colmv = credict_list.get("Columnmove", "")
    locmvcol = credict_list.get("LocationCellForMoveColumn", "")
    gencolnotchg = credict_list.get("GenneralColumnNotChange", "")
    genconraf = credict_list.get("GeneralConcernRaffter", "")
    gensel = credict_list.get("Genneral_Select", "")
    locrowleft = credict_list.get("LocationOfRowLeft", "")
    locrowright = credict_list.get("LocationOfRowRight", "")
    excemvcolright = credict_list.get("ExcelCellForMoveColumnRight", "")
    locpur = credict_list.get("LocationOfPurlin", "")
    strow = credict_list.get("startrow", "")

    # data template  
    if IsRunningInPyinstallerBundle():
        #NameFile = ExtractFileNameFromPath(DataExcel)
        DataExcel = resource_path_is_from_pyinstall_and_dev(FileName = 'DataALL - Template.xlsx',
                                                         Subfolder="Data",
                                                         Is_Directory_Path_To_SubFolder= True,
                                                         dir_path=sys._MEIPASS)

    else:
        # get file excel from template excel (full path)
        DataExcel = PathSteel(modulename =templatexc,
                             FileName ='DataALL - Template.xlsx')\
                            .getpathmodule()
            
        """
        DataExcel = os.path.join((os.path.dirname(templatexc.__file__)),
                                'DataALL - Template.xlsx') 
        """

    book = load_workbook(DataExcel)
    writer = ExcelWriter(DataExcel,
                        engine='openpyxl')
    writer.book = book
    writer.sheets = dict((ws.title, ws) for ws in book.worksheets)

    for path in [Left_Genneral_All_path,
                Right_Genneral_All_path]:
            
            df1 = pd.read_csv(path, delimiter=',',
                                    index_col = 0)
            dfCount = df1.shape
            df1.to_csv(path)
            #write Left to Excel 
            dfValueGeneral = pd.read_csv(path, 
                                        delimiter=',',
                                        usecols  = valgen,
                                        nrows= 1)

            dfValueGeneral.to_excel(writer,'General Member',
                                    index=False,header=True ,
                                    startcol=0,startrow \
                                    = strow[0])

            worksheet = writer.sheets['General Member']

            # create frame to excel 
            excellframe = toexcel(worksheet = worksheet,
                                            path = path,
                                            path_conf =pathconf,
                                            lpath=Left_Genneral_All_path,
                                            rpath = Right_Genneral_All_path)

            if path == Left_Genneral_All_path:
                usecolsArr = locrowleft
                LocationMoveColumn = locmvcol
                #write path to excel 
                excellframe.wrivaltoexc()
            else:
                usecolsArr = locrowright
                LocationMoveColumn = excemvcolright
                #write path to excel 
                excellframe.wrivaltoexc()
            #Write genneral to excel
            DfChangegenneral = pd.read_csv(path,
                                         delimiter=',',
                                         usecols = gencolnotchg,
                                         nrows= 1 
                                         )

            DfChangegenneral.to_excel(writer,
                                    'General Member',
                                    index=False,
                                    header=True,
                                    startcol=0,
                                    startrow= int(usecolsArr[1])
                                    )

            #write Genneral Concern Raffter
            DfChangegenneral = pd.read_csv(path,
                                             delimiter=',',
                                             usecols = genconraf 
                                             )

            DfChangegenneral.to_excel(writer,
                                    'General Member',
                                    index=False,
                                    header=True ,
                                    startcol=0,
                                    startrow=int(usecolsArr[2])
                                    )

            #write genneral selected 
            DfChangegenneral = pd.read_csv(path,
                                     delimiter=',',
                                     usecols = gensel,
                                     nrows= 1)
            DfChangegenneral.to_excel(writer,
                                    'General Member',
                                    index=False,
                                    header=True ,
                                    startcol=0,
                                    startrow= int(usecolsArr[0])
                                    )

            #write purlin roof 
            DfChangegenneral = pd.read_csv(path,
                                         delimiter=',',
                                         usecols = locpur,
                                         nrows= 1)

            DfChangegenneral.to_excel(writer,
                                    'General Member',
                                    index=False,
                                    header=True ,
                                    startcol=0,
                                    startrow= int(usecolsArr[3]))
            worksheet = writer.sheets['General Member']

            #Wirte move Column to excel
            excellframe.writemovecol(LocationMoveColumn,
                                                colmv)
    # create full path from dirpath 
    path = PathSteel(dir_path =pathout,
                     FileName ='new_big_file.xlsx')\
                    .refpath()
    #path = os.path.join(pathout,'new_big_file.xlsx') 
    book.save(path) 
コード例 #7
0
 def openfile1(self, output):
     # get path full
     self.pathinout = getpathfromtk(output)
     # save as file path from path original
     pathst = PathSteel(pathorigrn=self.pathinout)
     pathst.saveasfiletopathAndopen()
コード例 #8
0
 def dowloadfilexcelfromeven(self, fullname):
     # save as file path from path original
     pathst = PathSteel(pathorigrn=fullname)
     pathst.saveasfiletopathAndopen()