From: "Ashley E Desimone" <ashley.e.desimone@intel.com>
To: devel@edk2.groups.io
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>,
Puja Pandya <puja.pandya@intel.com>,
Erik Bjorge <erik.c.bjorge@intel.com>,
Bret Barkelew <Bret.Barkelew@microsoft.com>,
Prince Agyeman <prince.agyeman@intel.com>
Subject: [edk2-stagin/EdkRepo] [PATCH V4 1/3] EdkRepo: Initial commit of workspace_maintenance.py
Date: Thu, 23 Apr 2020 12:09:31 -0700 [thread overview]
Message-ID: <20200423190933.43108-2-ashley.e.desimone@intel.com> (raw)
In-Reply-To: <20200423190933.43108-1-ashley.e.desimone@intel.com>
Add workspace_maintenance.py including the implementation
of generate_name_for_obsolete_backup()
Signed-off-by: Ashley E Desimone <ashley.e.desimone@intel.com>
Signed-off-by: Ashley E Desimone <ashley.e.desimone@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Puja Pandya <puja.pandya@intel.com>
Cc: Erik Bjorge <erik.c.bjorge@intel.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Prince Agyeman <prince.agyeman@intel.com>
---
.../workspace_maintenance/workspace_maintenance.py | 30 ++++++++++++++++++++++
setup.py | 4 +--
2 files changed, 32 insertions(+), 2 deletions(-)
create mode 100644 edkrepo/common/workspace_maintenance/workspace_maintenance.py
diff --git a/edkrepo/common/workspace_maintenance/workspace_maintenance.py b/edkrepo/common/workspace_maintenance/workspace_maintenance.py
new file mode 100644
index 0000000..d45759a
--- /dev/null
+++ b/edkrepo/common/workspace_maintenance/workspace_maintenance.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python3
+#
+## @file
+# workspace_maintenance.py
+#
+# Copyright (c) 2017- 2020, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+''' Contains shared workspace maintenance 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
diff --git a/setup.py b/setup.py
index 06a382b..af173bb 100755
--- a/setup.py
+++ b/setup.py
@@ -12,8 +12,8 @@ setup(name='edkrepo',
version='2.0.0',
description='The edkrepo tools',
packages=['edkrepo', 'edkrepo.commands', 'edkrepo.commands.arguments', 'edkrepo.commands.humble',
- 'edkrepo.git_automation', 'edkrepo.common', 'edkrepo.config', 'edkrepo.config.humble',
- 'edkrepo_manifest_parser', 'project_utils'],
+ 'edkrepo.git_automation', 'edkrepo.common', 'edkrepo.common.workspace_maintenance',
+ 'edkrepo.config', 'edkrepo.config.humble', 'edkrepo_manifest_parser', 'project_utils'],
package_data={
},
include_package_data=True,
--
2.16.2.windows.1
next prev parent reply other threads:[~2020-04-23 19:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-23 19:09 [edkrepo2-staging/EdkRepo] [PATCH V4 0/3] Add initial manifest repository support Ashley E Desimone
2020-04-23 19:09 ` Ashley E Desimone [this message]
2020-04-23 19:09 ` [edk2-staging/EdkRepo] [PATCH V4 2/3] EdkRepo: Add edkrepo/common/workspace_maintenance/manifest_repos_maintenance Ashley E Desimone
2020-04-23 19:09 ` [edk2-staging/EdkRepo] [PATCH V4 3/3] EdkRepo: Update pull_latest_manifest_repo to use pull_single_manifest_repo Ashley E Desimone
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200423190933.43108-2-ashley.e.desimone@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox