Skip to content

Commit 3f9f444

Browse files
committed
Restoring naming conv
1 parent 55ee3fb commit 3f9f444

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/iterative_telemetry/__init__.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,29 +199,26 @@ def _find_or_create_user_id():
199199
config_dir = user_config_dir(
200200
os.path.join("iterative", "telemetry"), "iterative"
201201
)
202-
user_id_file = os.path.join(config_dir, "user_id")
202+
fname = os.path.join(config_dir, "user_id")
203203
lockfile = os.path.join(config_dir, "user_id.lock")
204204

205-
# Since the `user_id_file` and `lockfile` are under the
206-
# global config, we need to make sure such directory exist
207-
# already.
205+
# Since the `fname` and `lockfile` are under the global config,
206+
# we need to make sure such directory exist already.
208207
os.makedirs(config_dir, exist_ok=True)
209-
210208
try:
211209
with FileLock( # pylint: disable=abstract-class-instantiated
212210
lockfile, timeout=5
213211
):
214-
215212
try:
216-
with open(user_id_file, encoding="utf8") as fobj:
213+
with open(fname, encoding="utf8") as fobj:
217214
user_id = json.load(fobj)["user_id"]
218215

219216
except (FileNotFoundError, ValueError, KeyError):
220217

221218
# Backwards compatibility with DVC legacy telemetry location.
222219
user_id = _try_read_legacy_user_id() or str(uuid.uuid4())
223220

224-
with open(user_id_file, "w", encoding="utf8") as fobj:
221+
with open(fname, "w", encoding="utf8") as fobj:
225222
json.dump({"user_id": user_id}, fobj)
226223

227224
return user_id
@@ -232,12 +229,10 @@ def _find_or_create_user_id():
232229

233230

234231
def _try_read_legacy_user_id():
235-
legacy_user_id_file = os.path.join(
236-
user_config_dir("dvc", "iterative"), "user_id"
237-
)
232+
fname = os.path.join(user_config_dir("dvc", "iterative"), "user_id")
238233

239234
try:
240-
with open(legacy_user_id_file, encoding="utf8") as fobj:
235+
with open(fname, encoding="utf8") as fobj:
241236
return json.load(fobj)["user_id"]
242237

243238
except (FileNotFoundError, ValueError, KeyError):

0 commit comments

Comments
 (0)