Example #1
0
def copierClasseurs(doc, nomFichiers):
    #    typ = doc.GetTypeEnseignement()
    #    ref = doc.GetReferentiel()
    prj = doc.GetProjetRef()
    fichiers = prj.grilles

    #    fichierPB = []

    for k, f in fichiers.items():
        shutil.copyfile(os.path.join(TABLE_PATH, toFileEncoding(f[0])),
                        toFileEncoding(nomFichiers[k]))
Example #2
0
 def setBranche(self, branche, pathdoc):
     self.path = toFileEncoding(branche.get("Lien", r""))
     self.path = os.path.normpath(self.path)
     self.type = branche.get("TypeLien", "")
     self.abs = eval(branche.get("Abs", "False"))
     if self.type == "" and self.path != r"":
         self.EvalTypeLien(pathdoc)
     return True
Example #3
0
    def ouvrir(fichier):
        fichier = os.path.join(TABLE_PATH, toFileEncoding(fichier))
        tableau = None
        err = 0

        if os.path.isfile(fichier):
            try:
                tableau = PyExcel(fichier)
            except:
                err = 1
        else:
            err = 2
            fichierPB.append(fichier)

        return err, tableau
Example #4
0
    def GetAbsPath(self, pathdoc, path = None):
        """ Renvoie le chemin absolu du lien
            grace au chemin du document <pathdoc>
        """
#         print("GetAbsPath", path, pathref)
        if path == None:
            path = self.path
            
        if path == ".":
            return pathdoc
        
        cwd = os.getcwd()
        if pathdoc != "":
            try:
                os.chdir(pathdoc)
            except:
                pass
        
#         print os.path.exists(path)
#         print os.path.exists(os.path.abspath(path))
#         print os.path.exists(os.path.abspath(path).decode(util_path.FILE_ENCODING))
        
        # Immonde bricolage !!
#         if os.path.exists(os.path.abspath(path)) and os.path.exists(os.path.abspath(path)):#.decode(util_path.FILE_ENCODING)):
#             path = path.decode(util_path.FILE_ENCODING)
        
        path = os.path.abspath(path)#.decode(util_path.FILE_ENCODING)
        
#         print("  abs >", path)
        if os.path.exists(path):
            path = path
        else:
#             print(path, "n'existe pas !")
            try:
                path = os.path.join(pathdoc, path)
            except UnicodeDecodeError:
                pathdoc = toFileEncoding(pathdoc)
                path = os.path.join(pathdoc, path)
        
        
        os.chdir(cwd)
        return path
Example #5
0
    def GetRelPath(self, pathdoc, path=None):
        """ Renvoie le chemin relatif du lien
            grace au chemin du document <pathdoc>
        """
        if path == None:
            path = self.path

        if self.type != 'f' and self.type != 'd':
            return path

#        path = self.GetEncode(path)
        if os.path.exists(path):
            path = path
        else:
            try:
                path = os.path.join(pathdoc, path)
            except UnicodeDecodeError:
                pathdoc = toFileEncoding(pathdoc)
                path = os.path.join(pathdoc, path)
        return path
Example #6
0
def getFullNameGrille(fichier):
    return os.path.join(TABLE_PATH, toFileEncoding(fichier))
Example #7
0
def getFullNameGrille(fichier):
    """ Renvoie le chemin du fichier Grille nommé <fichier>
    """
    return os.path.join(TABLE_PATH, toFileEncoding(fichier))