コード例 #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,
              wsheet=None,
              dpath=None,
              namefile=None,
              dicrowconf=None,
              wbnsct=None,
              pathconf=None):
     self.dicrowconf = dicrowconf
     self.dpath = dpath
     self.wsheet = wsheet
     self.namefile = namefile
     #max colum ws1
     self.mcol = self.wsheet.api.UsedRange.Columns.count
     #max row ws1
     self.mrow = self.wsheet.api.UsedRange.Rows.count
     self.dirpathconf = getdirpath(pathconf)
     self.__hm_rangege = (self.dicrowconf["hm_rangege"])
     self.numberhm = int(sepnumberandstrfromstr(self.__hm_rangege)[1])
     self.__wb1 = wbnsct
     listsheetnamehm = (self.dicrowconf["listsheetnamehm"])
     # return csv have list sheet name
     self.pathlsn = refullpath(dirpath=self.dirpathconf,
                               filename=listsheetnamehm)
     try:
         self.lsheet = convertcsvto1list(path=self.pathlsn)
     except:
         pass
コード例 #3
0
 def hdatafilechecked(self):
     """halding data value"""
     listcheked = self.cb.getCheckedItems()
     for eleexcell in listcheked:
         pathtocopy = refullpath(dirpath=self.pathin, filename=eleexcell)
         hexcel_child(pathtocopy=pathtocopy,
                      pathconf=self.pathconfig).runaz30azb60()
コード例 #4
0
 def getCheckedItem(self):
     """ get checked item """
     listcheked = self.cb.getCheckedItems()
     for eleexcell in listcheked:
         pathtocopy = refullpath(dirpath=self.pathin, filename=eleexcell)
         cexcel(pathdes=self.pathfilep,
                pathtocopy=pathtocopy,
                pathconf=self.pathconfig).copysheettoexcelexist()
コード例 #5
0
    def __init__(self, pathconf=None):
        self.__pathconf = pathconf
        dirparhconf = parentdirectory(self.__pathconf)
        dicrowconf = returndictrowforcsv(path=pathconf)
        self.__sheetnametor = dicrowconf["khns_sheetnamekhns"]
        self.__khns_namfile = dicrowconf["khns_namfile"]
        self.__khns_rangenumbermct_ptvt = dicrowconf[
            "khns_rangenumbermct_ptvt"]
        self.__valuenotnone = dicrowconf["valuenotnone"]
        self.__valueall = dicrowconf["valueall"]
        self.__dictvalue = dicrowconf["dictvalue"]
        self.__mvta = (dicrowconf["khns_mavatu"])
        self.__mvt = col2num(self.__mvta)

        #self.__fpath = returnactivewbpath(namefile=self.__khns_namfile)
        self.__fpath = activeworkbook_fullname()

        self.__rel = credict(pathfull=self.__fpath,
                             namesheet=self.__sheetnametor,
                             engine="xlwings",
                             rangea=self.__khns_rangenumbermct_ptvt)
        # csv for dict
        self.pathtovalue = refullpath(dirparhconf, self.__dictvalue)
        # csv for value
        self.valuenotnone = refullpath(dirparhconf, self.__valuenotnone)

        # csv for all value
        self.pathvalueall = refullpath(dirparhconf, self.__valueall)

        # get all key redic incule len != 0
        self.redic_all = self.__rel.redictvaluesandvaluecol(
            columnumber=self.__mvt, removeemtyvalue=False)

        #self.redic =self.__rel.redictvaluesandvaluecol(columnumber=self.__mvt)

        self.redic = {
            key: val
            for key, val in self.redic_all.items() if len(val) != 0
        }

        self.valueredicttocsv()
        self.valuelisttocsv()
コード例 #6
0
    def __transfertoparents(self):
        for name_ele_ex in self.__lsheet_ex:
            path_copy = refullpath(dirpath=self.__path_copy_dir,
                                   filename=name_ele_ex)
            copyxw = self.__app.books.open(fullname=path_copy,
                                           update_links=False,
                                           read_only=False,
                                           ignore_read_only_recommended=False)

            lkeys = list(self.__dictconf.keys())
            # lengh of sheet name key
            llen = len("sub_transfertoparents_namesheet")
            key_snames = [
                lkey[llen:] for lkey in lkeys
                if "sub_transfertoparents_namesheet" in lkey
            ]
            yerorno = self.__dictconf["transfertoparents"]
            for key_sname in key_snames:
                sheetname = self.__dictconf["sub_transfertoparents_namesheet" +
                                            key_sname]
                nstart_row = int(
                    self.__dictconf["sub_transfertoparents_recor_l1" +
                                    key_sname])
                valueim = self.__dictconf["sub_transfertoparents_valueim" +
                                          key_sname]
                msstr = self.__dictconf["sub_transfertoparents_ms" + key_sname]
                for_using_loc = self.__dictconf[
                    "sub_transfertoparents_forbydup" + key_sname]
                loc_use_formulas = self.__dictconf[
                    "sub_transfertoparents_locuseformulas" + key_sname]
                col_dup = self.__dictconf["sub_transfertoparents_dup" +
                                          key_sname]
                ws_copy = retrive_sname_sheet(copyxw=copyxw,
                                              desxw=self.__desxw,
                                              lsheet=[sheetname])
                # check ws_copy
                if ws_copy == None: continue
                # retrive sheet des and active
                self.__desxw.sheets[ws_copy.name].activate()
                # transer range  using VLOOLUP
                hchildsheet(startrow=nstart_row,
                            col_key_msa=msstr,
                            lcolumnformulas=loc_use_formulas,
                            valueim=valueim,
                            sheet_des=activesheet(),
                            sheet_copy=ws_copy,
                            col_dup=col_dup,
                            formulasfor_col_dup=for_using_loc
                            ) if yerorno == "yes" else False
            copyxw.close()
        self.__desxw.save()
        self.__desxw.close()
        self.__app.quit()
コード例 #7
0
    def __init__(self, pathconf=None):
        self.__pathconf = pathconf
        dictconf = returndictrowforcsv(path=pathconf)
        self.__hm_congtac = dictconf["hm_congtac"]
        self.__hm_bombt = dictconf["hm_bombt"]
        self.__hm_macmtc = dictconf["hm_macmtc"]
        self.__hm_materiasvattu = dictconf["hm_materiasvattu"]
        self.__hm_vlvk = dictconf["hm_vlvk"]
        self.__hm_VLTP = dictconf["hm_vltp"]
        self.__hm_MNCTP = dictconf["hm_mnctp"]

        self.__hm_VTKCT = dictconf["hm_vtkct"]
        self.__hm_NCKCT = dictconf["hm_nckct"]

        self.__hm_startpasterange = dictconf["hm_startpasterange"]
        sign_vk = dictconf["sign_vk"].replace(":", ",")
        self.sign_vk = returnlist_from_listinstr(sign_vk)
        sign_BT = dictconf["sign_bt"].replace(":", ",")
        self.sign_BT = returnlist_from_listinstr(sign_BT)
        self.__startpasterange = returnseplistintbbystr(
            self.__hm_startpasterange)

        self.pathlsn = refullpath(dirpath=getdirpath(pathconf),
                                  filename=dictconf["listsheetnamehm"])
        fct = dictconf["fct"]
        try:
            self.lsheetname = convertcsvto1list(path=self.pathlsn)
        except:
            pass
        fname = dictconf["khns_namfile"]
        if fct.strip() == "all":
            self.wb = activeworkbook(namefile=fname, checknamefile=True)
            for sheet in self.lsheetname:
                print(sheet)
                self.wb.sheets[sheet].activate()
                self.__sheetdesactive = activesheet()
                self.m_row = self.__sheetdesactive.range(
                    self.__hm_congtac +
                    str(self.__sheetdesactive.cells.last_cell.row)).end(
                        'up').row
                self.__hdata()
                #self.copyrangfromconf()
        else:
            self.__sheetdesactive = activesheet()
            #self.copyrangfromconf()
            self.m_row = self.__sheetdesactive.range(
                self.__hm_congtac +
                str(self.__sheetdesactive.cells.last_cell.row)).end('up').row
            self.__hdata()
コード例 #8
0
    def __Getlistsheet(self):
        self.__app = xw.App(visible=True, add_book=False)
        self.__wb1 = self.__app.books.open(self.pathtocopy, update_links=False)
        #self.__wb1  = xw.Book(self.pathtocopy)
        #self.__wb1  = book_by_path(path=self.pathtocopy, visible = False)
        self.names = self.__wb1.sheets
        self.lsheetname = [sheet.name for sheet in self.names]
        self.__ws1 = self.__wb1.sheets[self.names[0]]
        self.__wsname = self.__ws1.name
        # set active sheet

        #max row ws1
        self.rows = self.__ws1.api.UsedRange.Rows.count
        #max colum ws1
        self.cols = self.__ws1.api.UsedRange.Columns.count
        # check name sheet (have to have AZB)
        if self.namesheetchild in self.__wsname:
            pass
        else:
            messagebox.showerror(
                "error", "Name sheet must start \
                                from symbols {}...".format(
                    self.namesheetchild))

        self.__dirpath = getdirpath(self.pathtocopy)

        self.__fpath = refullpath(dirpath=self.__dirpath,
                                  filename=self.__namefile)

        #self.__wbthns  = book_by_path(path=self.__fpath, visible = False)
        #self.__wbthns  = xw.Book(self.__fpath)
        self.__wbthns = self.__app.books.open(
            self.__fpath,
            read_only=True,
            ignore_read_only_recommended=True,
            update_links=False)

        self.__wb1.sheets[self.__wsname].activate()

        if self.__wbthns == None:
            messagebox.showerror(
                "Error directory", "Directory {0} not exists, \
                                recheck Directory again Note: extension of excel maybe xls or xlsx,\
                                     check file config {1} have parameter 'khns_namfile'"
                .format(self.__fpath, self.pathconf))
コード例 #9
0
 def __init__(self, pathconf=None, pathconfigexcelcopy=None):
     # call dict
     self.pathconfigexcelcopy = pathconfigexcelcopy
     dictconf = returndictrowforcsv(path=pathconf)
     self.__hm_startcopyrange = dictconf["hm_startcopyrange"]
     self.fname = dictconf["khns_namfile"]
     self.__startcopyrange = returnseplistintbbystr(
         self.__hm_startcopyrange)
     self.__hm_startpasterange = dictconf["hm_startpasterange"]
     self.__hm_hangmuc = dictconf["hm_hangmuc"]
     # copy another range botton
     self.__hm_startcopyrangebt = dictconf["hm_startcopyrange_bt"]
     self.__startcopyrangebt = returnseplistintbbystr(
         self.__hm_startcopyrangebt)
     self.__hm_startpasterangebt = dictconf["hm_startpasterange_bt"]
     self.pathlsn = refullpath(dirpath=getdirpath(pathconf),
                               filename=dictconf["listsheetnamehm"])
     self.copyhm = dictconf["copyhm"]
コード例 #10
0
def rdict_path(dirpath=None,
               folderchild="config",
               namefiles=[
                   "logo.png", "hrdata_modified.csv", "conf_ex.xlsx",
                   "config_hm.xlsx", "key.key", "fn.csv", "seri.key", "ser.csv"
               ],
               keepextension=False):
    """ return dict of path """
    dict_path = {}
    for namefile in namefiles:
        if keepextension:
            keyd = folderchild + "_" + namefile
        else:
            keyd = folderchild + "_" + removeexfilename(namefile)

        keyd = folderchild + "_" + removeexfilename(namefile)
        dict_path[keyd] = p_pyinstall_and_dev(
            refullpath(dirpath=dirpath,
                       folderchild=folderchild,
                       filename=namefile))
    return dict_path
コード例 #11
0
    def __transfertoparent(self):
        lsheet = self.__dictconf["sub_transfertoparent_listsheetname"]
        for name_ele_ex in self.__lsheet_ex:
            path_copy = refullpath(dirpath=self.__path_copy_dir,
                                   filename=name_ele_ex)
            copyxw = self.__app.books.open(fullname=path_copy,
                                           update_links=False,
                                           read_only=False,
                                           ignore_read_only_recommended=False)
            ws_copy = retrive_sname_sheet(copyxw=copyxw,
                                          desxw=self.__desxw,
                                          lsheet=lsheet)
            # check ws_copy
            if ws_copy == None: continue
            # retrive parameter from file excel config
            yerorno = self.__dictconf["transfertoparent"]
            nstart_row = int(self.__dictconf["sub_transfertoparent_recor_l1"])
            valueim = self.__dictconf["sub_transfertoparent_valueim"]
            msstr = self.__dictconf["sub_transfertoparent_ms"]
            for_using_loc = self.__dictconf["sub_transfertoparent_forbydup"]
            loc_use_formulas = self.__dictconf[
                "sub_transfertoparent_locuseformulas"]
            col_dup = self.__dictconf["sub_transfertoparent_dup"]
            # retrive sheet des and active
            self.__desxw.sheets[ws_copy.name].activate()
            ws_des = activesheet()
            hchildsheet(startrow=nstart_row,
                        col_key_msa=msstr,
                        lcolumnformulas=loc_use_formulas,
                        valueim=valueim,
                        sheet_des=activesheet(),
                        sheet_copy=ws_copy,
                        col_dup=col_dup,
                        formulasfor_col_dup=for_using_loc
                        ) if yerorno == "yes" else False

            copyxw.close()
        self.__desxw.save()
        self.__desxw.close()
        self.__app.quit()
コード例 #12
0
    def mfolderopenchild(self):
        """ open folder of child files"""
        try:
            closeallfileexcel(namek_ofpname="AZB")
        except:
            pass
        self.output1.delete(0, 'end')
        # ask directory
        files = filedialog.askdirectory(title="Directory of child files",
                                        initialdir=self.output1.get())
        self.output1.insert(tk.END, files)
        # get path from entry
        self.pathin = getpathfromtk(self.output1)
        try:
            self.scf.destroy()
        except:
            pass
        self.scf = scrollbarvn(parent=self.frameb, bg="white")
        self.scframe = self.scf.frame
        if self.pathin:
            # return list in folder
            fpexcel = listfileinfolder(self.pathin)
            # filter file in folder
            plist = filterlistbylstr(criteria=["AZB"], liststr=fpexcel)

            # return list path excel sheeet
            lpsheet = [
                refullpath(dirpath=self.pathin, filename=fpname)
                for fpname in plist
            ]

            # return list sheet excel
            lsexcel = listexcel(l_ex=lpsheet).returnlsheet()
            # create check list box
            self.cb = ChecklistBox(parent=self.scframe,
                                   choices=plist,
                                   listsheetname=lsexcel,
                                   width=123)
コード例 #13
0
from pynvn.excel.copypasteexell import cprange
import xlwings as xw
from pynvn.csv.rcsv import returndictrowforcsv
from pynvn.string.slist import returnseplistintbbystr
from pynvn.excel import activesheet,activeworkbook
from pynvn.csv.tolist import convertcsvto1list
from pynvn.path.ppath import refullpath,getdirpath
def conf_csvtolist (pathconf,path_csvtoconverttolist)
    """ copy sheet and change value cell """
    # call dict 
    dictconf = returndictrowforcsv(path=pathconf)
    # return csv have list sheet name 
    self.pathlsn = refullpath(dirpath=self.dirpathconf,
                                        filename=listsheetnamehm)
    copyhm = dictconf["copyhm"]
    try:                        
        self.lsheetname = convertcsvto1list(path=path_csvtoconverttolist)
    except:
        pass
コード例 #14
0
    def __init__(self, root=None):
        self.root = root
        dirname = os.path.dirname(__file__)

        # ===================================

        self.imagelogopath = resource_path_is_from_pyinstall_and_dev(
            refullpath(dirpath=dirname, folderchild="img",
                       filename="logo.png"))

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

        self.pathconfig = resource_path_is_from_pyinstall_and_dev(
            refullpath(dirpath=dirname,
                       folderchild="config",
                       filename="hrdata_modified.csv"))

        self.pathconfigexell = resource_path_is_from_pyinstall_and_dev(
            refullpath(dirpath=dirname,
                       folderchild="config",
                       filename="conf_ex.xlsx"))

        # path to config of excel to copy

        self.pathconfigexcelcopy = resource_path_is_from_pyinstall_and_dev(
            refullpath(dirpath=dirname,
                       folderchild="config",
                       filename="config_hm.xlsx"))

        # for license key
        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"))

        self.azb = azbg(
            root=self.root,
            imagelogopath=self.imagelogopath,
            pathconfig=self.pathconfig,
            pathconfigexell=self.pathconfigexell,
            imagelogo=self.imagelogo,
            pathconfigexcelcopy=self.pathconfigexcelcopy,
        )
        key_license(root=self.root,
                    pathtokey=self.pathtokey,
                    pathtovaluecsv_key=self.pathtovaluecsv_key,
                    ser_key=self.ser_key,
                    valueser_key=self.valueser_key,
                    classofoject=self.azb)
コード例 #15
0
    def __init__ (self, fpath = None,
                        pathconf = None,
                        pathconfigexcelcopy = None
                        ):
        self.pathconf = pathconf
        self.pathconfigexcelcopy = pathconfigexcelcopy
        self.dicrowconf = returndictrowforcsv(path=pathconf)
        self.__fpath = fpath
        dirparhconf = parentdirectory(pathconf)
        self.__sheetnametor=self.dicrowconf["khns_sheetnamekhns"]
        self.__namefile=self.dicrowconf["khns_namfile"]
        self.__rangeg =self.dicrowconf["hm_rangege"]

        self.__rangeintct = returnseplistintbbystr(self.__rangeg)

        self.__rangestrct = returnliststr_from_str(self.__rangeg)

        self.__mvta = (self.dicrowconf["khns_mavatu"])
        self.__mvt = col2num (self.__mvta)
        self.__khns_ndcva = (self.dicrowconf["khns_noidungcongviec"])
        self.__khns_ndcv = col2num (self.__khns_ndcva)
        self.__khns_dvta = (self.dicrowconf["khns_dvt"])
        self.__khns_dvt = col2num (self.__khns_dvta)

        self.__khns_muchaophi = (self.dicrowconf["khns_muchaophi"])

        self.__khns_muchaophi_int = col2num(self.__khns_muchaophi)

        self.__hm_mvt = int(self.dicrowconf["hm_mvt"])
        self.__hm_ndcv = int(self.dicrowconf["hm_noidungcongviec"])
        self.__hm_dvt = int(self.dicrowconf["hm_dvt"])

        self.__hm_dgth_str = (self.dicrowconf["hm_dgth"])

        self.__hm_dgth = col2num(self.__hm_dgth_str)

        self.__hm_ttnt_str = (self.dicrowconf["hm_ttnt"])
        self.__hm_ttnt = col2num(self.__hm_ttnt_str)

        self.__hm_startrowvalue = int(self.dicrowconf["hm_startrowvalue"])
        self.__hm_vta = self.dicrowconf["hm_vt"]
        self.__hm_nca = self.dicrowconf["hm_nc"]
        self.__hm_mtca = self.dicrowconf["hm_mtc"]
        self.__hm_tha = self.dicrowconf["hm_th"]

        self.__hm_ct = self.dicrowconf["hm_ct"]
        self.__hm_ct_int = col2num(self.__hm_ct)

        self.__hm_vt =col2num (self.dicrowconf["hm_vt"]) 
        self.__hm_nc =col2num (self.dicrowconf["hm_nc"]) 
        self.__hm_mtc =col2num (self.dicrowconf["hm_mtc"])
        self.__hm_th =col2num (self.dicrowconf["hm_th"])
        self.__valuenotnone =self.dicrowconf["valuenotnone"]
        valueall =self.dicrowconf["valueall"]
        self.__dictvalue =self.dicrowconf["dictvalue"]
        # csv for dict 
        self.pathtovalue = refullpath(dirparhconf,self.__dictvalue)
        # csv for value 
        self.valuenotnone = refullpath(dirparhconf,self.__valuenotnone)
        # path all value 
        self.pathvalueall = refullpath(dirparhconf,valueall)

        self.__khns_rangenumbermct_ptvt =self.dicrowconf["khns_rangenumbermct_ptvt"]
        # hangmuccongtac 
        self.__hm_startpasterange = self.dicrowconf["hm_startpasterange"]
        self.__startpasterange = returnseplistintbbystr(self.__hm_startpasterange)
        self.__hm_congtac = self.dicrowconf["hm_congtac"]
        # add new##########################################################################33
        
        self.__khns_macongtac = self.dicrowconf["khns_macongtac"]
        self.__khns_noidungcongviec = self.dicrowconf["khns_noidungcongviec"]
        self.__khns_vattu = self.dicrowconf["khns_vattu"]
        self.__khns_nhancong = self.dicrowconf["khns_nhancong"]
        self.__khns_maytc = self.dicrowconf["khns_maytc"]
        
        self.__hm_th_formulas = self.dicrowconf["hm_th_formulas"]

        self.__khns_startrow = int(self.dicrowconf["khns_startrow"])
        # return list ma cong tac not node in cell value of ptvl by csv
        self.getvaluelist = convertcsvtolist(path=self.valuenotnone)
        # return all value from csv 
        self.getallvalue = convertcsvtolist(path=self.pathvalueall)

   
        self.pathlsn = refullpath(dirpath=getdirpath(pathconf),
                                        filename=self.dicrowconf["listsheetnamehm"])

        try:                        
            self.lsheetname = convertcsvto1list(path=self.pathlsn)
        except:
            pass
        self.__returnothervalue()
        self.__returnlistcongtac()