當前位置: 首頁>>代碼示例>>Python>>正文


Python Manifest.addentry方法代碼示例

本文整理匯總了Python中pants.java.jar.manifest.Manifest.addentry方法的典型用法代碼示例。如果您正苦於以下問題:Python Manifest.addentry方法的具體用法?Python Manifest.addentry怎麽用?Python Manifest.addentry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pants.java.jar.manifest.Manifest的用法示例。


在下文中一共展示了Manifest.addentry方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: safe_classpath

# 需要導入模塊: from pants.java.jar.manifest import Manifest [as 別名]
# 或者: from pants.java.jar.manifest.Manifest import addentry [as 別名]
def safe_classpath(classpath, synthetic_jar_dir):
  """Bundles classpath into one synthetic jar that includes original classpath in its manifest.

  This is to ensure classpath length never exceeds platform ARG_MAX.

  :param list classpath: Classpath to be bundled.
  :param string synthetic_jar_dir: directory to store the synthetic jar, if `None`
    a temp directory will be provided and cleaned up upon process exit. Otherwise synthetic
    jar will remain in the supplied directory, only for debugging purpose.

  :returns: A classpath (singleton list with just the synthetic jar).
  :rtype: list of strings
  """
  if synthetic_jar_dir:
    safe_mkdir(synthetic_jar_dir)
  else:
    synthetic_jar_dir = safe_mkdtemp()

  bundled_classpath = relativize_classpath(classpath, synthetic_jar_dir)

  manifest = Manifest()
  manifest.addentry(Manifest.CLASS_PATH, ' '.join(bundled_classpath))

  with temporary_file(root_dir=synthetic_jar_dir, cleanup=False, suffix='.jar') as jar_file:
    with open_zip(jar_file, mode='w', compression=ZIP_STORED) as jar:
      jar.writestr(Manifest.PATH, manifest.contents())
    return [jar_file.name]
開發者ID:dturner-tw,項目名稱:pants,代碼行數:29,代碼來源:util.py

示例2: safe_classpath

# 需要導入模塊: from pants.java.jar.manifest import Manifest [as 別名]
# 或者: from pants.java.jar.manifest.Manifest import addentry [as 別名]
def safe_classpath(classpath, synthetic_jar_dir, custom_name=None):
  """Bundles classpath into one synthetic jar that includes original classpath in its manifest.

  This is to ensure classpath length never exceeds platform ARG_MAX.

  :param list classpath: Classpath to be bundled.
  :param string synthetic_jar_dir: directory to store the synthetic jar, if `None`
    a temp directory will be provided and cleaned up upon process exit. Otherwise synthetic
    jar will remain in the supplied directory, only for debugging purpose.
  :param custom_name: filename of the synthetic jar to be created.

  :returns: A classpath (singleton list with just the synthetic jar).
  :rtype: list of strings
  """
  if synthetic_jar_dir:
    safe_mkdir(synthetic_jar_dir)
  else:
    synthetic_jar_dir = safe_mkdtemp()

  # Quote the paths so that if they contain reserved characters can be safely passed to JVM classloader.
  bundled_classpath = map(urllib.quote, relativize_classpath(classpath, synthetic_jar_dir))

  manifest = Manifest()
  manifest.addentry(Manifest.CLASS_PATH, ' '.join(bundled_classpath))

  with temporary_file(root_dir=synthetic_jar_dir, cleanup=False, suffix='.jar') as jar_file:
    with open_zip(jar_file, mode='w', compression=ZIP_STORED) as jar:
      jar.writestr(Manifest.PATH, manifest.contents())

    if custom_name:
      custom_path = os.path.join(synthetic_jar_dir, custom_name)
      safe_concurrent_rename(jar_file.name, custom_path)
      return [custom_path]
    else:
      return [jar_file.name]
開發者ID:baroquebobcat,項目名稱:pants,代碼行數:37,代碼來源:util.py

示例3: bundled_classpath

# 需要導入模塊: from pants.java.jar.manifest import Manifest [as 別名]
# 或者: from pants.java.jar.manifest.Manifest import addentry [as 別名]
def bundled_classpath(classpath):
  """Bundles classpath into one synthetic jar that includes original classpath in its manifest.

  See https://docs.oracle.com/javase/7/docs/technotes/guides/extensions/spec.html#bundled

  :param list classpath: Classpath to be bundled.

  :returns: A classpath (singleton list with just the synthetic jar).
  :rtype: list of strings
  """
  def prepare_url(url):
    url_in_bundle = os.path.realpath(url)
    # append '/' for directories, those not ending with '/' are assumed to be jars
    if os.path.isdir(url):
      url_in_bundle += '/'
    return url_in_bundle

  bundled_classpath = [prepare_url(url) for url in classpath]

  manifest = Manifest()
  manifest.addentry(Manifest.CLASS_PATH, ' '.join(bundled_classpath))

  with temporary_file(cleanup=False, suffix='.jar') as jar_file:
    with open_zip(jar_file, mode='w', compression=ZIP_STORED) as jar:
      jar.writestr(Manifest.PATH, manifest.contents())
    yield [jar_file.name]
開發者ID:Gabriel439,項目名稱:pants,代碼行數:28,代碼來源:util.py

示例4: safe_classpath

# 需要導入模塊: from pants.java.jar.manifest import Manifest [as 別名]
# 或者: from pants.java.jar.manifest.Manifest import addentry [as 別名]
def safe_classpath(classpath, synthetic_jar_dir):
  """Bundles classpath into one synthetic jar that includes original classpath in its manifest.

  This is to ensure classpath length never exceeds platform ARG_MAX. Original classpath are
  converted to URLs relative to synthetic jar path and saved in its manifest as attribute
  `Class-Path`. See
  https://docs.oracle.com/javase/7/docs/technotes/guides/extensions/spec.html#bundled

  :param list classpath: Classpath to be bundled.
  :param string synthetic_jar_dir: directory to store the synthetic jar, if `None`
    a temp directory will be provided and cleaned up upon process exit. Otherwise synthetic
    jar will remain in the supplied directory, only for debugging purpose.

  :returns: A classpath (singleton list with just the synthetic jar).
  :rtype: list of strings
  """
  def prepare_url(url, root_dir):
    url_in_bundle = os.path.relpath(os.path.realpath(url), os.path.realpath(root_dir))
    # append '/' for directories, those not ending with '/' are assumed to be jars
    if os.path.isdir(url):
      url_in_bundle += '/'
    return url_in_bundle

  if synthetic_jar_dir:
    safe_mkdir(synthetic_jar_dir)
  else:
    synthetic_jar_dir = safe_mkdtemp()
  bundled_classpath = [prepare_url(url, synthetic_jar_dir) for url in classpath]

  manifest = Manifest()
  manifest.addentry(Manifest.CLASS_PATH, ' '.join(bundled_classpath))

  with temporary_file(root_dir=synthetic_jar_dir, cleanup=False, suffix='.jar') as jar_file:
    with open_zip(jar_file, mode='w', compression=ZIP_STORED) as jar:
      jar.writestr(Manifest.PATH, manifest.contents())
    return [jar_file.name]
開發者ID:megaserg,項目名稱:pants,代碼行數:38,代碼來源:util.py

示例5: _write_agent_manifest

# 需要導入模塊: from pants.java.jar.manifest import Manifest [as 別名]
# 或者: from pants.java.jar.manifest.Manifest import addentry [as 別名]
 def _write_agent_manifest(agent, jar):
   # TODO(John Sirois): refactor an agent model to support 'Boot-Class-Path' properly.
   manifest = Manifest()
   manifest.addentry(Manifest.MANIFEST_VERSION, '1.0')
   if agent.premain:
     manifest.addentry('Premain-Class', agent.premain)
   if agent.agent_class:
     manifest.addentry('Agent-Class', agent.agent_class)
   if agent.can_redefine:
     manifest.addentry('Can-Redefine-Classes', 'true')
   if agent.can_retransform:
     manifest.addentry('Can-Retransform-Classes', 'true')
   if agent.can_set_native_method_prefix:
     manifest.addentry('Can-Set-Native-Method-Prefix', 'true')
   jar.writestr(Manifest.PATH, manifest.contents())
開發者ID:arloherrine,項目名稱:pants,代碼行數:17,代碼來源:jar_task.py

示例6: test_nonascii_char

# 需要導入模塊: from pants.java.jar.manifest import Manifest [as 別名]
# 或者: from pants.java.jar.manifest.Manifest import addentry [as 別名]
 def test_nonascii_char(self):
   manifest = Manifest()
   with self.assertRaises(UnicodeEncodeError):
     manifest.addentry('X-Copyright', '© 2015')
開發者ID:foursquare,項目名稱:pants,代碼行數:6,代碼來源:test_manifest.py

示例7: test_too_long_entry

# 需要導入模塊: from pants.java.jar.manifest import Manifest [as 別名]
# 或者: from pants.java.jar.manifest.Manifest import addentry [as 別名]
 def test_too_long_entry(self):
   manifest = Manifest()
   with self.assertRaises(ValueError):
     manifest.addentry(
       '1234567890123456789012345678901234567890'
       '12345678901234567890123456789', 'value')
開發者ID:foursquare,項目名稱:pants,代碼行數:8,代碼來源:test_manifest.py

示例8: test_addentry

# 需要導入模塊: from pants.java.jar.manifest import Manifest [as 別名]
# 或者: from pants.java.jar.manifest.Manifest import addentry [as 別名]
 def test_addentry(self):
   manifest = Manifest()
   manifest.addentry('Header', 'value')
   self.assertEquals(
     'Header: value\n', manifest.contents())
開發者ID:foursquare,項目名稱:pants,代碼行數:7,代碼來源:test_manifest.py

示例9: test_isempty

# 需要導入模塊: from pants.java.jar.manifest import Manifest [as 別名]
# 或者: from pants.java.jar.manifest.Manifest import addentry [as 別名]
 def test_isempty(self):
   manifest = Manifest()
   self.assertTrue(manifest.is_empty())
   manifest.addentry('Header', 'value')
   self.assertFalse(manifest.is_empty())
開發者ID:foursquare,項目名稱:pants,代碼行數:7,代碼來源:test_manifest.py


注:本文中的pants.java.jar.manifest.Manifest.addentry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。