Ejemplo n.º 1
0
def test_workspace_gdb():
    ws = paths.Workspace('test.gdb',
                         qualifier='TEST',
                         base='C:\\temp',
                         separator='|')
    assert ws.root == paths.Workspace('C:\\temp\\test.gdb')
    assert ws.qualifier == ''
    assert ws.separator == ''
    assert ws.make_path('test_table') == 'C:\\temp\\test.gdb\\test_table'
    assert ws.make_path('', 'root_fc') == 'C:\\temp\\test.gdb\\root_fc'
    assert ws.make_path('ele',
                        'ele_kabel') == 'C:\\temp\\test.gdb\\ele\\ele_kabel'
    ws = paths.Workspace('C:\\temp\\test.gdb')
    assert not ws.exists
    assert ws.root == paths.Workspace('C:\\temp\\test.gdb')
    assert ws.get_parent(str(ws)) == 'C:\\temp\\test.gdb'
    assert ws.get_parent(str(ws), True) == 'C:\\temp'
    assert ws.get_root(str(ws)) == 'C:\\temp\\test.gdb'
    assert ws.is_gdb is True
    assert ws.qualifier == ''
    assert ws.separator == ''
    assert ws.qualify('test', 'my_qualifier') == 'test'
    with pytest.raises(ValueError):
        ws.qualify('')
    assert ws.make_path('ele',
                        'ele_kabel') == 'C:\\temp\\test.gdb\\ele\\ele_kabel'
    with pytest.raises(IndexError):
        ws.make_path('p1', 'p2', 'p3')
    assert paths.Workspace.get_root('C:\\temp\\test.shp') == 'C:\\temp'
    assert paths.Workspace.get_parent('C:\\temp\\test.shp') == 'C:\\temp'
    assert ws.get_root(
        'C:\\temp\\test.gdb\\ele\\ele_kabel') == 'C:\\temp\\test.gdb'
Ejemplo n.º 2
0
def test_workspace_mem():
    ws = paths.Workspace('in_memory')
    assert ws.root == paths.Workspace('in_memory')
    assert ws.qualifier == ''
    assert ws.separator == ''
    assert ws.make_path('ele', 'ele_kabel') == 'in_memory\\ele\\ele_kabel'
    assert paths.Workspace.get_parent(str(ws)) == 'in_memory'
    assert paths.Workspace.get_parent(str(ws), True) == 'in_memory'
    assert ws.get_root(str(ws)) == 'in_memory'
    assert ws.is_gdb is True
Ejemplo n.º 3
0
    def workspace(self):
        """
        Returns a :class:`gpf.paths.Workspace` instance for the Esri workspace
        (and optionally a qualifier) specified in the script arguments.

        :rtype:    gpf.paths.Workspace
        """
        qualifier = self._store.get(self._DB_QUALIFIER, _const.CHAR_EMPTY)
        ws_path = self._store.get(self._WORKSPACE_PATH)
        return _paths.Workspace(ws_path, qualifier)
Ejemplo n.º 4
0
def test_getworkspace():
    assert paths.get_workspace('C:\\temp\\test.gdb\\feature_dataset\\feature_class') == \
           paths.Workspace('C:\\temp\\test.gdb\\feature_dataset')
    assert paths.get_workspace(
        'C:\\temp\\test.gdb\\feature_dataset\\feature_class',
        True) == paths.Workspace('C:\\temp\\test.gdb')
Ejemplo n.º 5
0
    def __init__(self, plan, workspace=None, **kwargs):

        self._gpn = _const.CHAR_EMPTY   # GP abbreviation (e.g. "GP", "PW" etc.)
        self._num = _const.CHAR_EMPTY   # GP number (e.g. 1, 2, 3, 1001 etc.)
        self._pfx = _const.CHAR_EMPTY   # User prefix with underscore (e.g. "U_")
        self._workspace = None          # Reference to the Workspace

        if workspace:
            self._workspace = workspace if isinstance(workspace, _paths.Workspace) else _paths.Workspace(workspace)

        self._parse(plan, kwargs.get(self.__ARG_PFX, self.__USER_PFX).upper())