当前位置: 首页>>代码示例>>Python>>正文


Python synthtool.replace函数代码示例

本文整理汇总了Python中synthtool.replace函数的典型用法代码示例。如果您正苦于以下问题:Python replace函数的具体用法?Python replace怎么用?Python replace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了replace函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1:

    config_path='/google/devtools/artman_clouddebugger.yaml',
    artman_output_name='google-cloud-ruby/google-cloud-debugger'
)
s.copy(v2_library / 'lib/google/cloud/debugger/v2')
s.copy(v2_library / 'lib/google/cloud/debugger/v2.rb')
s.copy(v2_library / 'lib/google/devtools')
s.copy(v2_library / 'test/google/cloud/debugger/v2')

# PERMANENT: Handwritten layer owns Debugger.new so low-level clients need to
# use Debugger::V2.new instead of Debugger.new(version: :v2). Update the
# examples and tests.
s.replace(
    [
      'lib/google/cloud/debugger/v2/controller2_client.rb',
      'lib/google/cloud/debugger/v2/debugger2_client.rb',
      'test/google/cloud/debugger/v2/controller2_client_test.rb',
      'test/google/cloud/debugger/v2/debugger2_client_test.rb'
    ],
    'require "google/cloud/debugger"',
    'require "google/cloud/debugger/v2"')
s.replace(
    [
      'lib/google/cloud/debugger/v2/controller2_client.rb',
      'test/google/cloud/debugger/v2/controller2_client_test.rb'
    ],
    'Google::Cloud::Debugger::Controller2\\.new\\(version: :v2\\)',
    'Google::Cloud::Debugger::V2::Controller2.new')
s.replace(
    [
      'lib/google/cloud/debugger/v2/debugger2_client.rb',
      'test/google/cloud/debugger/v2/debugger2_client_test.rb'
开发者ID:beautiful-code,项目名称:gcloud-ruby,代码行数:31,代码来源:synth.py

示例2:

# Generate admin client
library = gapic.py_library(
    "bigtable_admin",
    "v2",
    config_path="/google/bigtable/admin/artman_bigtableadmin.yaml",
    artman_output_name="bigtable-admin-v2",
    include_protos=True,
)

s.move(library / "google/cloud/bigtable_admin_v2")
s.move(library / "tests")

s.replace(
    [
        "google/cloud/bigtable_admin_v2/gapic/bigtable_instance_admin_client.py",
        "google/cloud/bigtable_admin_v2/gapic/bigtable_table_admin_client.py",
    ],
    "'google-cloud-bigtable-admin'",
    "'google-cloud-bigtable'",
)

s.replace(
    "google/**/*.py",
    "from google\.cloud\.bigtable\.admin_v2.proto",
    "from google.cloud.bigtable_admin_v2.proto",
)

s.replace(
    [
        "google/cloud/bigtable_admin_v2/gapic/transports/"
        "bigtable_table_admin_grpc_transport.py",
        "google/cloud/bigtable_v2/gapic/transports/bigtable_grpc_transport.py",
开发者ID:tswast,项目名称:gcloud-python,代码行数:32,代码来源:synth.py

示例3:

    # Don't move over __init__.py, as we modify it to make the generated client
    # use helpers.py.
    s.move(library / f"google/cloud/speech_{version}/types.py")
    s.move(library / f"google/cloud/speech_{version}/gapic")
    s.move(library / f"google/cloud/speech_{version}/proto")
    s.move(library / f"tests/unit/gapic/{version}")
    s.move(library / f"docs/gapic/{version}")


# Use the highest version library to generate documentation import alias.
s.move(library / "google/cloud/speech.py")

# Issues exist where python files should define the source encoding
# https://github.com/googleapis/gapic-generator/issues/2097
s.replace("**/proto/*_pb2.py", r"(^.*$\n)*", r"# -*- coding: utf-8 -*-\n\g<0>")


# Fix tests to use the direct gapic client instead of the wrapped helper
# client.
s.replace(
    "tests/unit/**/test*client*.py",
    r"from google\.cloud import speech_(.+?)$",
    r"from google.cloud.speech_\1.gapic import speech_client as speech_\1",
)

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(unit_cov_level=97, cov_level=100)
s.move(templated_files)
开发者ID:dhermes,项目名称:gcloud-python,代码行数:30,代码来源:synth.py

示例4:

)
s.copy(v1beta2_library / 'lib/google/cloud/language/v1beta2')
s.copy(v1beta2_library / 'lib/google/cloud/language/v1beta2.rb')
s.copy(v1beta2_library / 'lib/google/cloud/language/v1beta2')
s.copy(v1beta2_library / 'test/google/cloud/language/v1beta2')

# Copy common templates
templates = gcp.CommonTemplates().ruby_library()
s.copy(templates)

# https://github.com/googleapis/gapic-generator/issues/2196
s.replace(
    [
      'README.md',
      'lib/google/cloud/language.rb',
      'lib/google/cloud/language/v1.rb',
      'lib/google/cloud/language/v1beta2.rb'
    ],
    '\\[Product Documentation\\]: https://cloud\\.google\\.com/language\n',
    '[Product Documentation]: https://cloud.google.com/natural-language\n')

# https://github.com/googleapis/gapic-generator/issues/2243
s.replace(
    'lib/google/cloud/language/*/*_client.rb',
    '(\n\\s+class \\w+Client\n)(\\s+)(attr_reader :\\w+_stub)',
    '\\1\\2# @private\n\\2\\3')

# https://github.com/googleapis/gapic-generator/issues/2279
s.replace(
    'lib/**/*.rb',
    '\\A(((#[^\n]*)?\n)*# (Copyright \\d+|Generated by the protocol buffer compiler)[^\n]+\n(#[^\n]*\n)*\n)([^\n])',
开发者ID:GoogleCloudPlatform,项目名称:gcloud-ruby,代码行数:31,代码来源:synth.py

示例5: escape_braces

v1beta1_library = gapic.ruby_library(
    'asset', 'v1beta1', artman_output_name='google-cloud-ruby/google-cloud-asset',
    config_path='artman_cloudasset_v1beta1.yaml'
)
s.copy(v1beta1_library / 'lib/google/cloud/asset/v1beta1.rb')
s.copy(v1beta1_library / 'lib/google/cloud/asset/v1beta1')
s.copy(v1beta1_library / 'test/google/cloud/asset/v1beta1')

# Copy common templates
templates = gcp.CommonTemplates().ruby_library()
s.copy(templates)

# https://github.com/googleapis/gapic-generator/issues/2180
s.replace(
    'google-cloud-asset.gemspec',
    '\n  gem\\.add_dependency "google-gax", "~> ([\\d\\.]+)"\n\n',
    '\n  gem.add_dependency "google-gax", "~> \\1"\n  gem.add_dependency "grpc-google-iam-v1", "~> 0.6.9"\n\n')

# https://github.com/googleapis/gapic-generator/issues/2232
s.replace(
    'lib/google/cloud/asset/**/asset_service_client.rb',
    '\n\n(\\s+)class OperationsClient < Google::Longrunning::OperationsClient',
    '\n\n\\1# @private\n\\1class OperationsClient < Google::Longrunning::OperationsClient')

# https://github.com/googleapis/gapic-generator/issues/2242


def escape_braces(match):
    expr = re.compile('^([^`]*(`[^`]*`[^`]*)*)([^`#\\$\\\\])\\{([\\w,]+)\\}')
    content = match.group(0)
    while True:
开发者ID:GoogleCloudPlatform,项目名称:gcloud-ruby,代码行数:31,代码来源:synth.py

示例6:

        config_path=f'artman_cloudasset_{lower_version}.yaml',
        artman_output_name=f'google-cloud-asset-{lower_version}')

    # copy all src including partial veneer classes
    s.move(library / 'src')

    # copy proto files to src also
    s.move(library / f'proto/src/Google/Cloud/Asset', f'src/')
    s.move(library / f'tests/')

    # copy GPBMetadata file to metadata
    s.move(library / f'proto/src/GPBMetadata/Google/Cloud/Asset', f'metadata/')

# fix year
s.replace(
    'src/V1beta1/**/*.php',
    r'Copyright \d{4}',
    r'Copyright 2018')
s.replace(
    'tests/*/V1beta1/*Test.php',
    r'Copyright \d{4}',
    r'Copyright 2018')
s.replace(
    'src/V1/**/*.php',
    r'Copyright \d{4}',
    r'Copyright 2019')
s.replace(
    'tests/*/V1/*Test.php',
    r'Copyright \d{4}',
    r'Copyright 2019')
开发者ID:jdpedrie,项目名称:gcloud-php,代码行数:30,代码来源:synth.py

示例7:

import synthtool as s
from synthtool import gcp

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()
versions = ["v1beta1", "v1"]

# ----------------------------------------------------------------------------
# Generate securitycenter GAPIC layer
# ----------------------------------------------------------------------------
for version in versions:
    library = gapic.py_library("securitycenter", version, include_protos=True)
    s.move(library / f"google/cloud/securitycenter_{version}")
    s.move(library / f"tests/unit/gapic/{version}")
    s.move(library / f"docs/gapic/{version}")

# Use the highest version library to generate import alias.
s.move(library / "google/cloud/securitycenter.py")

# Add encoding header to protoc-generated files.
# See: https://github.com/googleapis/gapic-generator/issues/2097
s.replace("**/proto/*_pb2.py", r"(^.*$\n)*", r"# -*- coding: utf-8 -*-\n\g<0>")

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(unit_cov_level=97, cov_level=100)
s.move(templated_files, excludes=['noxfile.py'])

s.shell.run(["nox", "-s", "blacken"], hide_output=False)
开发者ID:GoogleCloudPlatform,项目名称:gcloud-python,代码行数:30,代码来源:synth.py

示例8:

gapic = gcp.GAPICGenerator()

version = 'v1'


library = gapic.py_library(
    'pubsub', version, config_path='/google/pubsub/artman_pubsub.yaml')
s.move(
    library,
    excludes=[
        'docs/**/*', 'nox.py', 'README.rst', 'setup.py',
        'google/cloud/pubsub_v1/__init__.py', 'google/cloud/pubsub_v1/types.py'])

# Adjust tests to import the clients directly.
s.replace(
    'tests/unit/gapic/v1/test_publisher_client_v1.py',
    'from google.cloud import pubsub_v1',
    'from google.cloud.pubsub_v1.gapic import publisher_client')

s.replace(
    'tests/unit/gapic/v1/test_publisher_client_v1.py',
    ' pubsub_v1',
    ' publisher_client')

s.replace(
    'tests/unit/gapic/v1/test_subscriber_client_v1.py',
    'from google.cloud import pubsub_v1',
    'from google.cloud.pubsub_v1.gapic import subscriber_client')

s.replace(
    'tests/unit/gapic/v1/test_subscriber_client_v1.py',
    ' pubsub_v1',
开发者ID:longfengpili,项目名称:google-cloud-python,代码行数:32,代码来源:synth.py

示例9: escape_braces

s.copy(v1beta1_library / 'lib/google/cloud/error_reporting/v1beta1')
s.copy(v1beta1_library / 'lib/google/devtools/clouderrorreporting/v1beta1')

# Omitting lib/google/cloud/error_reporting/v1beta1.rb for now because we are
# not exposing the low-level API.

# https://github.com/googleapis/gapic-generator/issues/2242
def escape_braces(match):
    expr = re.compile('^([^`]*(`[^`]*`[^`]*)*)([^`#\\$\\\\])\\{([\\w,]+)\\}')
    content = match.group(0)
    while True:
        content, count = expr.subn('\\1\\3\\\\\\\\{\\4}', content)
        if count == 0:
            return content
s.replace(
    'lib/google/cloud/error_reporting/v1beta1/**/*.rb',
    '\n(\\s+)#[^\n]*[^\n#\\$\\\\]\\{[\\w,]+\\}',
    escape_braces)

# https://github.com/googleapis/gapic-generator/issues/2243
s.replace(
    'lib/google/cloud/error_reporting/v1beta1/*_client.rb',
    '(\n\\s+class \\w+Client\n)(\\s+)(attr_reader :\\w+_stub)',
    '\\1\\2# @private\n\\2\\3')

# https://github.com/googleapis/gapic-generator/issues/2279
s.replace(
    'lib/**/*.rb',
    '\\A(((#[^\n]*)?\n)*# (Copyright \\d+|Generated by the protocol buffer compiler)[^\n]+\n(#[^\n]*\n)*\n)([^\n])',
    '\\1\n\\6')
开发者ID:GoogleCloudPlatform,项目名称:gcloud-ruby,代码行数:30,代码来源:synth.py

示例10: dedent

v1p3beta1 = gapic.ruby_library(
    'vision', 'v1p3beta1',
    artman_output_name='google-cloud-ruby/google-cloud-vision'
)
s.copy(v1p3beta1 / 'lib/google/cloud/vision/v1p3beta1')
s.copy(v1p3beta1 / 'lib/google/cloud/vision/v1p3beta1.rb')
s.copy(v1p3beta1 / 'acceptance/google/cloud/vision/v1p3beta1')
s.copy(v1p3beta1 / 'test/google/cloud/vision/v1p3beta1')

# PERMANENT: Add migration guide to docs
s.replace(
    'lib/google/cloud/vision.rb',
    '# ### Preview',
    dedent("""\
      # ### Migration Guide
          #
          # The 0.32.0 release introduced breaking changes relative to the previous
          # release, 0.31.0. For more details and instructions to migrate your code,
          # please visit the [migration
          # guide](https://cloud.google.com/vision/docs/ruby-client-migration).
          #
          # ### Preview"""))

# PERMANENT: Add migration guide to readme
s.replace(
    'README.md',
    '### Preview\n',
    dedent("""\
      ### Migration Guide

      The 0.32.0 release introduced breaking changes relative to the previous release,
      0.31.0. For more details and instructions to migrate your code, please visit the
开发者ID:beautiful-code,项目名称:gcloud-ruby,代码行数:32,代码来源:synth.py

示例11:

    version='v2',
    artman_output_name='google-cloud-dialogflow-v2')

# copy all src including partial veneer classes
s.move(library / 'src')

# copy proto files to src also
s.move(library / 'proto/src/Google/Cloud/Dialogflow', 'src/')
s.move(library / 'tests/')

# copy GPBMetadata file to metadata
s.move(library / 'proto/src/GPBMetadata/Google/Cloud/Dialogflow', 'metadata/')

# fix year
s.replace(
    '**/Gapic/*GapicClient.php',
    r'Copyright \d{4}',
    'Copyright 2018')
for client in ['Agents', 'Contexts', 'EntityTypes', 'Intents', 'SessionEntityTypes', 'Sessions']:
    s.replace(
        f'**/V1/{client}Client.php',
        r'Copyright \d{4}',
        'Copyright 2018')
s.replace(
    'tests/**/V2/*Test.php',
    r'Copyright \d{4}',
    'Copyright 2018')

# Change the wording for the deprecation warning.
s.replace(
    'src/*/*_*.php',
    r'will be removed in the next major release',
开发者ID:caedmonm,项目名称:experiments,代码行数:32,代码来源:synth.py

示例12: many

# ----------------------------------------------------------------------------
# Generate dlp GAPIC layer
# ----------------------------------------------------------------------------
library = gapic.py_library(
    "irm",
    "v1alpha2",
    config_path="/google/cloud/irm/artman_irm_v1alpha2.yaml",
    include_protos=True,
)

excludes = ["README.rst", "nox*.py", "setup.py", "docs/index.rst"]
s.move(library, excludes=excludes)

# Fix docstrings
s.replace("google/**/*.py", r"\\_", "_")
s.replace("google/**/incidents_service_pb2.py", r"""\\\*""", r"""*""")
s.replace("google/**/incident_service_client.py", r"""\\\*""", r"""*""")
s.replace(
    "google/**/incident_service_client.py",
    r"""        This will fail if:
           a\. there are too many \(50\) subscriptions in the incident already
           b\. a subscription using the given channel already exists""",
    r"""        This will fail if:
        a. there are too many (50) subscriptions in the incident already
        b. a subscription using the given channel already exists""",
)

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
开发者ID:GoogleCloudPlatform,项目名称:gcloud-python,代码行数:30,代码来源:synth.py

示例13: escape_braces

    'kms', 'v1', artman_output_name='google-cloud-ruby/google-cloud-kms',
    config_path='artman_cloudkms.yaml'
)
s.copy(v1_library / 'lib')
s.copy(v1_library / 'test')
s.copy(v1_library / 'README.md')
s.copy(v1_library / 'LICENSE')
s.copy(v1_library / '.gitignore')
s.copy(v1_library / '.yardopts')
s.copy(v1_library / 'google-cloud-kms.gemspec', merge=ruby.merge_gemspec)

# PERMANENT: API name for cloudkms
s.replace(
    [
      'README.md',
      'lib/google/cloud/kms.rb',
      'lib/google/cloud/kms/v1.rb'
    ],
    '/kms\\.googleapis\\.com', '/cloudkms.googleapis.com')

# https://github.com/googleapis/gapic-generator/issues/2242
def escape_braces(match):
    expr = re.compile('^([^`]*(`[^`]*`[^`]*)*)([^`#\\$\\\\])\\{([\\w,]+)\\}')
    content = match.group(0)
    while True:
        content, count = expr.subn('\\1\\3\\\\\\\\{\\4}', content)
        if count == 0:
            return content
s.replace(
    'lib/google/cloud/**/*.rb',
    '\n(\\s+)#[^\n]*[^\n#\\$\\\\]\\{[\\w,]+\\}',
开发者ID:beautiful-code,项目名称:gcloud-ruby,代码行数:31,代码来源:synth.py


注:本文中的synthtool.replace函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。