1
# ubuntuone.u1sync.utils
3
# Miscellaneous utility functions
5
# Author: Tim Cole <tim.cole@canonical.com>
7
# Copyright 2009 Canonical Ltd.
9
# This program is free software: you can redistribute it and/or modify it
10
# under the terms of the GNU General Public License version 3, as published
11
# by the Free Software Foundation.
13
# This program is distributed in the hope that it will be useful, but
14
# WITHOUT ANY WARRANTY; without even the implied warranties of
15
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
16
# PURPOSE. See the GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License along
19
# with this program. If not, see <http://www.gnu.org/licenses/>.
20
"""Miscellaneous utility functions."""
22
from errno import EEXIST, ENOENT
23
from ubuntuone.u1sync.constants import (
24
METADATA_DIR_NAME, SPECIAL_FILE_RE)
26
from ubuntuone.platform import (
31
def should_sync(filename):
32
"""Returns True if the filename should be synced.
34
@param filename: a unicode filename
37
return filename != METADATA_DIR_NAME and \
38
not SPECIAL_FILE_RE.match(filename)
41
"""Creates a directory if it does not already exist."""
48
def safe_unlink(path):
49
"""Unlinks a file if it exists."""