Esempio n. 1
0
def normalize_tree_french(root, simulate = False):
  r"""
  This function is just a call to anormalize.normalize_tree
  using the adevaccents.normaliser_nom_de_fichier_utf8 function.
  As a consequence of this,
  this function renames all directories and filenames in the given
  directory, so that they only contain displayable and allowed ASCII
  characters. The resulting filenames will only contain bytes that
  satisfy all these conditions:
  - displayable ASCII (ie. bytes in range 0x20 - 0x7e)
  - allowed in UNIX (ie. is not a '/')
  - allowed in Windows (ie. is not one of: \/:*?"<>|)
  This program will try to replace French accents by the
  unaccented letters, as long as they are written in UTF-8
  in the original filename.

  For documentation which is general to the tree processing
  (ie. which is independant from the renaming function used),
  see the anormalize.normalize_tree source.
  """
  anormalize.normalize_tree(root = root,
      renamefunc = adevaccents.normaliser_nom_de_fichier_utf8,
      simulate = simulate)
Esempio n. 2
0
def normalize_tree_french(root, simulate=False):
    r"""
  This function is just a call to anormalize.normalize_tree
  using the adevaccents.normaliser_nom_de_fichier_utf8 function.
  As a consequence of this,
  this function renames all directories and filenames in the given
  directory, so that they only contain displayable and allowed ASCII
  characters. The resulting filenames will only contain bytes that
  satisfy all these conditions:
  - displayable ASCII (ie. bytes in range 0x20 - 0x7e)
  - allowed in UNIX (ie. is not a '/')
  - allowed in Windows (ie. is not one of: \/:*?"<>|)
  This program will try to replace French accents by the
  unaccented letters, as long as they are written in UTF-8
  in the original filename.

  For documentation which is general to the tree processing
  (ie. which is independant from the renaming function used),
  see the anormalize.normalize_tree source.
  """
    anormalize.normalize_tree(
        root=root,
        renamefunc=adevaccents.normaliser_nom_de_fichier_utf8,
        simulate=simulate)
Esempio n. 3
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

# By Raphael CHAMPEIMONT, in the public domain.
# See anormalizefrench for documentation.
# WARNING: Only tested under UNIX!

import anormalize
import sys
import re

_myregex1 = re.compile('^ +')
_myregex2 = re.compile(' +$')


def trimspaces(s):
    s = _myregex1.sub('', s)
    s = _myregex2.sub('', s)
    return s


if len(sys.argv) < 2:
    print "An argument should be given: the root directory."
    sys.exit(1)

root = sys.argv[1]

anormalize.normalize_tree(root, renamefunc=trimspaces, simulate=False)
Esempio n. 4
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

# By Raphael CHAMPEIMONT, in the public domain.

# This script renames all files in given directory and all subdirectories
# when they contain characters forbidden in Windows filesystems:
# \/:*?"<>|
# The typical usage of this script is to prepare a copy of a file tree from
# a Linux filesystem (which allows this characters) to a Windows one.
# This one is just a simulation, ie. only displays what it would rename
# if it were not a simulation.

import anormalize
import sys

if len(sys.argv) < 2:
    print "An argument should be given: the root directory."
    sys.exit(1)

root = sys.argv[1]

print "Script start"
anormalize.normalize_tree(root=root,
                          renamefunc=anormalize.renamefunc_windows,
                          simulate=True)
print "Script end"
Esempio n. 5
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

# By Raphael CHAMPEIMONT, in the public domain.
# See anormalize.py for documentation.
# WARNING: Only tested under UNIX!

import anormalize
import sys

if len(sys.argv) < 2:
    print "An argument should be given: the root directory."
    sys.exit(1)

root = sys.argv[1]

anormalize.normalize_tree(root=root)
#!/usr/bin/python
# -*- coding: utf-8 -*-

# By Raphael CHAMPEIMONT, in the public domain.

# This script renames all files in given directory and all subdirectories
# when they contain characters forbidden in Windows filesystems:
# \/:*?"<>|
# The typical usage of this script is to prepare a copy of a file tree from
# a Linux filesystem (which allows this characters) to a Windows one.

import anormalize
import sys

if len(sys.argv) < 2:
    print "An argument should be given: the root directory."
    sys.exit(1)

root = sys.argv[1]

print "Script start"
anormalize.normalize_tree(root=root, renamefunc=anormalize.renamefunc_windows)
print "Script end"
Esempio n. 7
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

# By Raphael CHAMPEIMONT, in the public domain.
# See anormalize.py for documentation.
# WARNING: Only tested under UNIX!

import anormalize
import sys

if len(sys.argv) < 2:
    print "An argument should be given: the root directory."
    sys.exit(1)

root = sys.argv[1]

anormalize.normalize_tree(root=root, simulate=True)
Esempio n. 8
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

# By Raphael CHAMPEIMONT, in the public domain.

# This script renames all files in given directory and all subdirectories
# when they contain characters forbidden in Windows filesystems:
# \/:*?"<>|
# The typical usage of this script is to prepare a copy of a file tree from
# a Linux filesystem (which allows this characters) to a Windows one.

import anormalize
import sys

if len(sys.argv) < 2:
  print "An argument should be given: the root directory."
  sys.exit(1)

root = sys.argv[1]

print "Script start"
anormalize.normalize_tree(root = root, renamefunc = anormalize.renamefunc_windows)
print "Script end"
#!/usr/bin/python
# -*- coding: utf-8 -*-

# By Raphael CHAMPEIMONT, in the public domain.

# This script renames all files in given directory and all subdirectories
# when they contain characters forbidden in Windows filesystems:
# \/:*?"<>|
# The typical usage of this script is to prepare a copy of a file tree from
# a Linux filesystem (which allows this characters) to a Windows one.
# This one is just a simulation, ie. only displays what it would rename
# if it were not a simulation.

import anormalize
import sys

if len(sys.argv) < 2:
  print "An argument should be given: the root directory."
  sys.exit(1)

root = sys.argv[1]

print "Script start"
anormalize.normalize_tree(root = root, renamefunc = anormalize.renamefunc_windows, simulate = True)
print "Script end"
Esempio n. 10
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

# By Raphael CHAMPEIMONT, in the public domain.
# See anormalize.py for documentation.
# WARNING: Only tested under UNIX!

import anormalize
import sys

if len(sys.argv) < 2:
  print "An argument should be given: the root directory."
  sys.exit(1)

root = sys.argv[1]

anormalize.normalize_tree(root = root)
#!/usr/bin/python
# -*- coding: utf-8 -*-

# By Raphael CHAMPEIMONT, in the public domain.
# See anormalize.py for documentation.
# WARNING: Only tested under UNIX!

import anormalize
import sys

if len(sys.argv) < 2:
  print "An argument should be given: the root directory."
  sys.exit(1)

root = sys.argv[1]

anormalize.normalize_tree(root = root, simulate = True)
Esempio n. 12
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

# By Raphael CHAMPEIMONT, in the public domain.
# See anormalizefrench for documentation.
# WARNING: Only tested under UNIX!

import anormalize
import sys
import re

_myregex1 = re.compile('^ +')
_myregex2 = re.compile(' +$')

def trimspaces(s):
  s = _myregex1.sub('', s)
  s = _myregex2.sub('', s)
  return s

if len(sys.argv) < 2:
  print "An argument should be given: the root directory."
  sys.exit(1)

root = sys.argv[1]

anormalize.normalize_tree(root, renamefunc = trimspaces, simulate = False)