<commit_before># Copyright 2014 Google Inc. All Rights Reserved.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#     http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Setup script for OpenHTF."""


import glob
import os
import subprocess

from distutils.command.build import build
from distutils.command.clean import clean
from distutils.cmd import Command
from setuptools import find_packages
from setuptools import setup


class BuildClientCommand(Command):
  """Build OpenHTF frontend client."""
  description = "Builds the client javascript."""
  user_options = build.user_options + [
      ('clientdir=', 'c', 'Location of client directory.'),
      ('regenproto', 'r', 'True to regenerate the js proto files.'),
      ('npmpath=', 'n', 'Path to npm')]

  def initialize_options(self):
    self.clientdir = './openhtf/frontend/client'
    self.regenproto = False  # change to true when pbjs is fixed
    self.npmpath = '/usr/local/bin/npm'

  def finalize_options(self):
    pass

  def run(self):
    if self.regenproto:
      subprocess.check_call([self.npmpath, 'run', 'build:proto'],
                            cwd=self.clientdir)
    subprocess.check_call([self.npmpath, 'run', 'build'], cwd=self.clientdir)
    build.run(self)


class BuildProtoCommand(Command):
  """Custom setup command to build protocol buffers."""
  description = "Builds the proto files into python files."""
  user_options = [('grpc-python-plugin=', None, 'Path to the grpc py plugin.'),
                  ('protoc=', None, 'Path to the protoc compiler.'),
                  ('protodir=', None, 'Path to proto files.'),
                  ('outdir=', 'o', 'Where to output .py files.')]

  def initialize_options(self):
    self.grpc_python_plugin = './bin/grpc_python_plugin'
    self.protoc = './bin/protoc'
    self.protodir = './openhtf/proto'
    self.outdir = './openhtf/proto'

  def finalize_options(self):
    pass

  def run(self):
    # Build regular proto files.
    protos = glob.glob(os.path.join(self.protodir, '*.proto'))
    if protos:
      print "Attempting to build regular protos:\n%s" % '\n'.join(protos)
      subprocess.check_call([
          self.protoc,
          '-I', self.protodir,
          '--python_out', self.outdir,
          ] + protos)<commit_msg>Fix build_proto to point to new .proto file location in openhtf/io/proto<commit_after># Copyright 2014 Google Inc. All Rights Reserved.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#     http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Setup script for OpenHTF."""


import glob
import os
import subprocess

from distutils.command.build import build
from distutils.command.clean import clean
from distutils.cmd import Command
from setuptools import find_packages
from setuptools import setup


class BuildClientCommand(Command):
  """Build OpenHTF frontend client."""
  description = "Builds the client javascript."""
  user_options = build.user_options + [
      ('clientdir=', 'c', 'Location of client directory.'),
      ('regenproto', 'r', 'True to regenerate the js proto files.'),
      ('npmpath=', 'n', 'Path to npm')]

  def initialize_options(self):
    self.clientdir = './openhtf/frontend/client'
    self.regenproto = False  # change to true when pbjs is fixed
    self.npmpath = '/usr/local/bin/npm'

  def finalize_options(self):
    pass

  def run(self):
    if self.regenproto:
      subprocess.check_call([self.npmpath, 'run', 'build:proto'],
                            cwd=self.clientdir)
    subprocess.check_call([self.npmpath, 'run', 'build'], cwd=self.clientdir)
    build.run(self)


class BuildProtoCommand(Command):
  """Custom setup command to build protocol buffers."""
  description = "Builds the proto files into python files."""
  user_options = [('grpc-python-plugin=', None, 'Path to the grpc py plugin.'),
                  ('protoc=', None, 'Path to the protoc compiler.'),
                  ('protodir=', None, 'Path to proto files.'),
                  ('outdir=', 'o', 'Where to output .py files.')]

  def initialize_options(self):
    self.grpc_python_plugin = './bin/grpc_python_plugin'
    self.protoc = './bin/protoc'
    self.protodir = './openhtf/io/proto'
    self.outdir = './openhtf/io/proto'

  def finalize_options(self):
    pass

  def run(self):
    # Build regular proto files.
    protos = glob.glob(os.path.join(self.protodir, '*.proto'))
    if protos:
      print "Attempting to build regular protos:\n%s" % '\n'.join(protos)
      subprocess.check_call([
          self.protoc,
          '-I', self.protodir,
          '--python_out', self.outdir,
          ] + protos)
{'fraction_non_alphanumeric': 0.11969393332118783, 'fraction_numerical': 0.0029149207505920934, 'mean_word_length': 3.236111111111111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6751938', 'n_tokens_mistral': 1648, 'n_tokens_neox': 1608, 'n_words': 537}