from __future__ import absolute_import, division, print_function

import argparse
import os
from locale import getpreferredencoding
from os.path import abspath

from conda.compat import PY3

from conda_build.index import update_index


def main():
    p = argparse.ArgumentParser(
        description="Update package index metadata files in given directories")

    p.add_argument('dir',
                   help='Directory that contains an index to be updated.',
                   nargs='*',
                   default=[os.getcwd()])

    p.add_argument('-c', "--check-md5",
                   action="store_true",
                   help="Use MD5 values instead of file modification times for\
                         determining if a package's metadata needs to be \
                         updated.")

    p.add_argument('-f', "--force",
                   action="store_true",
                   help="force reading all files")

    p.add_argument('-q', "--quiet",
                   action="store_true")

    args = p.parse_args()

    dir_paths = [abspath(path) for path in args.dir]
    # Don't use byte strings in Python 2
    if not PY3:
        dir_paths = [path.decode(getpreferredencoding()) for path in dir_paths]

    for path in dir_paths:
        update_index(path, verbose=(not args.quiet), force=args.force)


if __name__ == '__main__':
    main()

from __future__ import absolute_import, division, print_function

import os
from locale import getpreferredencoding
from os.path import abspath

from conda.compat import PY3
from conda.cli.conda_argparse import ArgumentParser

from conda_build.index import update_index


def main():
    p = ArgumentParser(
        description="Update package index metadata files in given directories.")

    p.add_argument(
        'dir',
        help='Directory that contains an index to be updated.',
        nargs='*',
        default=[os.getcwd()],
    )

    p.add_argument(
        '-c', "--check-md5",
        action="store_true",
        help="""Use MD5 values instead of file modification times for determining if a
        package's metadata needs to be updated.""",
    )

    p.add_argument(
        '-f', "--force",
        action="store_true",
        help="Force reading all files.",
    )

    p.add_argument(
        '-q', "--quiet",
        action="store_true",
        help="Don't show any output.",
    )

    args = p.parse_args()

    dir_paths = [abspath(path) for path in args.dir]
    # Don't use byte strings in Python 2
    if not PY3:
        dir_paths = [path.decode(getpreferredencoding()) for path in dir_paths]

    for path in dir_paths:
        update_index(path, verbose=(not args.quiet), force=args.force)


if __name__ == '__main__':
    main()

Update command docs for conda index
Update command docs for conda index

  from __future__ import absolute_import, division, print_function
  
- import argparse
  import os
  from locale import getpreferredencoding
  from os.path import abspath
  
  from conda.compat import PY3
+ from conda.cli.conda_argparse import ArgumentParser
  
  from conda_build.index import update_index
  
  
  def main():
-     p = argparse.ArgumentParser(
+     p = ArgumentParser(
-         description="Update package index metadata files in given directories")
+         description="Update package index metadata files in given directories.")
  
-     p.add_argument('dir',
+     p.add_argument(
+         'dir',
-                    help='Directory that contains an index to be updated.',
+         help='Directory that contains an index to be updated.',
-                    nargs='*',
+         nargs='*',
-                    default=[os.getcwd()])
+         default=[os.getcwd()],
+     )
  
-     p.add_argument('-c', "--check-md5",
+     p.add_argument(
+         '-c', "--check-md5",
-                    action="store_true",
+         action="store_true",
-                    help="Use MD5 values instead of file modification times for\
+         help="""Use MD5 values instead of file modification times for determining if a
-                          determining if a package's metadata needs to be \
-                          updated.")
+         package's metadata needs to be updated.""",
+     )
  
-     p.add_argument('-f', "--force",
+     p.add_argument(
+         '-f', "--force",
-                    action="store_true",
+         action="store_true",
-                    help="force reading all files")
+         help="Force reading all files.",
+     )
  
-     p.add_argument('-q', "--quiet",
+     p.add_argument(
+         '-q', "--quiet",
-                    action="store_true")
+         action="store_true",
+         help="Don't show any output.",
+     )
  
      args = p.parse_args()
  
      dir_paths = [abspath(path) for path in args.dir]
      # Don't use byte strings in Python 2
      if not PY3:
          dir_paths = [path.decode(getpreferredencoding()) for path in dir_paths]
  
      for path in dir_paths:
          update_index(path, verbose=(not args.quiet), force=args.force)
  
  
  if __name__ == '__main__':
      main()
  
Update command docs for conda index
## Code Before:
from __future__ import absolute_import, division, print_function

import argparse
import os
from locale import getpreferredencoding
from os.path import abspath

from conda.compat import PY3

from conda_build.index import update_index


def main():
    p = argparse.ArgumentParser(
        description="Update package index metadata files in given directories")

    p.add_argument('dir',
                   help='Directory that contains an index to be updated.',
                   nargs='*',
                   default=[os.getcwd()])

    p.add_argument('-c', "--check-md5",
                   action="store_true",
                   help="Use MD5 values instead of file modification times for\
                         determining if a package's metadata needs to be \
                         updated.")

    p.add_argument('-f', "--force",
                   action="store_true",
                   help="force reading all files")

    p.add_argument('-q', "--quiet",
                   action="store_true")

    args = p.parse_args()

    dir_paths = [abspath(path) for path in args.dir]
    # Don't use byte strings in Python 2
    if not PY3:
        dir_paths = [path.decode(getpreferredencoding()) for path in dir_paths]

    for path in dir_paths:
        update_index(path, verbose=(not args.quiet), force=args.force)


if __name__ == '__main__':
    main()

## Instruction:
Update command docs for conda index
## Code After:
from __future__ import absolute_import, division, print_function

import os
from locale import getpreferredencoding
from os.path import abspath

from conda.compat import PY3
from conda.cli.conda_argparse import ArgumentParser

from conda_build.index import update_index


def main():
    p = ArgumentParser(
        description="Update package index metadata files in given directories.")

    p.add_argument(
        'dir',
        help='Directory that contains an index to be updated.',
        nargs='*',
        default=[os.getcwd()],
    )

    p.add_argument(
        '-c', "--check-md5",
        action="store_true",
        help="""Use MD5 values instead of file modification times for determining if a
        package's metadata needs to be updated.""",
    )

    p.add_argument(
        '-f', "--force",
        action="store_true",
        help="Force reading all files.",
    )

    p.add_argument(
        '-q', "--quiet",
        action="store_true",
        help="Don't show any output.",
    )

    args = p.parse_args()

    dir_paths = [abspath(path) for path in args.dir]
    # Don't use byte strings in Python 2
    if not PY3:
        dir_paths = [path.decode(getpreferredencoding()) for path in dir_paths]

    for path in dir_paths:
        update_index(path, verbose=(not args.quiet), force=args.force)


if __name__ == '__main__':
    main()
