Hi Ashley,

There is a misspelling, "maitenance" should be "maintenance". Other than that, 
looks good.

Thanks,
Nate

On 4/22/20, 4:29 PM, "Desimone, Ashley E" <ashley.e.desim...@intel.com> wrote:

    Add workspace_maitenance.py including the implementation
    of generate_name_for_obsolete_backup()

    Signed-off-by: Ashley E Desimone <ashley.e.desim...@intel.com>
    Cc: Nate DeSimone <nathaniel.l.desim...@intel.com>
    Cc: Puja Pandya <puja.pan...@intel.com>
    Cc: Erik Bjorge <erik.c.bjo...@intel.com>
    Cc: Bret Barkelew <bret.barke...@microsoft.com>
    Cc: Prince Agyeman <prince.agye...@intel.com>
    ---
     .../workspace_maitenance/workspace_maitenance.py   | 30 
++++++++++++++++++++++
     1 file changed, 30 insertions(+)
     create mode 100644 
edkrepo/common/workspace_maitenance/workspace_maitenance.py

    diff --git a/edkrepo/common/workspace_maitenance/workspace_maitenance.py 
b/edkrepo/common/workspace_maitenance/workspace_maitenance.py
    new file mode 100644
    index 0000000..83204f8
    --- /dev/null
    +++ b/edkrepo/common/workspace_maitenance/workspace_maitenance.py
    @@ -0,0 +1,30 @@
    +#!/usr/bin/env python3
    +#
    +## @file
    +# workspace_maitenance.py
    +#
    +# Copyright (c) 2017- 2020, Intel Corporation. All rights reserved.<BR>
    +# SPDX-License-Identifier: BSD-2-Clause-Patent
    +#
    +
    +''' Contains shared workspace maitenance functions. '''
    +
    +import os
    +
    +def generate_name_for_obsolete_backup(absolute_path):
    +    if not os.path.exists(absolute_path):
    +        raise ValueError("{} does not exist".format(absolute_path))
    +    original_name = os.path.basename(absolute_path)
    +    dir_name = os.path.dirname(absolute_path)
    +    unique_name = ""
    +    unique_name_found = False
    +    index = 1
    +    while not unique_name_found:
    +        if index == 1:
    +            unique_name = "{}_old".format(original_name)
    +        else:
    +            unique_name = "{}_old{}".format(original_name, index)
    +        if not os.path.exists(os.path.join(dir_name, unique_name)):
    +            unique_name_found = True
    +        index += 1
    +    return unique_name
    \ No newline at end of file
    -- 
    2.16.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#57991): https://edk2.groups.io/g/devel/message/57991
Mute This Topic: https://groups.io/mt/73209016/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to