From 0c1f45afd289220c9162538a93354e946eefb502 Mon Sep 17 00:00:00 2001 From: Vitalii Gridnev Date: Mon, 22 Aug 2022 19:40:02 +0300 Subject: [PATCH] improve example: avoid os.path.join --- examples/basic_example_v1/basic_example.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/basic_example_v1/basic_example.py b/examples/basic_example_v1/basic_example.py index c47e74dc..d1c1642c 100644 --- a/examples/basic_example_v1/basic_example.py +++ b/examples/basic_example_v1/basic_example.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import os - +import posixpath import ydb import basic_example_data @@ -258,7 +257,7 @@ def callee(session): def describe_table(pool, path, name): def callee(session): - result = session.describe_table(os.path.join(path, name)) + result = session.describe_table(posixpath.join(path, name)) print("\n> describe table: series") for column in result.columns: print("column, name:", column.name, ",", str(column.type.item).strip()) @@ -277,7 +276,7 @@ def bulk_upsert(table_client, path): .add_column("air_date", ydb.OptionalType(ydb.PrimitiveType.Uint64)) ) rows = basic_example_data.get_episodes_data_for_bulk_upsert() - table_client.bulk_upsert(os.path.join(path, "episodes"), rows, column_types) + table_client.bulk_upsert(posixpath.join(path, "episodes"), rows, column_types) def is_directory_exists(driver, path): @@ -291,11 +290,11 @@ def ensure_path_exists(driver, database, path): paths_to_create = list() path = path.rstrip("/") while path not in ("", database): - full_path = os.path.join(database, path) + full_path = posixpath.join(database, path) if is_directory_exists(driver, full_path): break paths_to_create.append(full_path) - path = os.path.dirname(path).rstrip("/") + path = posixpath.dirname(path).rstrip("/") while len(paths_to_create) > 0: full_path = paths_to_create.pop(-1) @@ -310,7 +309,7 @@ def run(endpoint, database, path): ensure_path_exists(driver, database, path) - full_path = os.path.join(database, path) + full_path = posixpath.join(database, path) create_tables(pool, full_path)