From 74f9da9da15e891557dfc578a1009bfe81fb92df Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Wed, 25 May 2016 20:23:37 -0700 Subject: [PATCH] artf2612: Added Python script for updating license in source files (#57) This is a follow-up of 3cd1253. A C++ program was written to automate the license update originally. That program was translated to Python so it can be kept in the repository and run when needed. It has been tested on Windows using the standard Python 3 installation and on Linux. The original version skipped files that had "//" at the beginning since most were files that should be excluded. The relevant files are now in an exclusion list and the rest are processed normally. The .hpp file extension has been added as well. The script rewrote CompressorJNI.cpp to remove the carriage returns from its line endings. --- hal/include/HAL/Accelerometer.h | 7 + hal/include/HAL/AnalogAccumulator.h | 7 + hal/include/HAL/AnalogInput.h | 7 + hal/include/HAL/AnalogOutput.h | 7 + hal/include/HAL/AnalogTrigger.h | 7 + hal/include/HAL/CAN.h | 7 + hal/include/HAL/Compressor.h | 10 +- hal/include/HAL/Counter.h | 7 + hal/include/HAL/DIO.h | 7 + hal/include/HAL/Encoder.h | 7 + hal/include/HAL/Errors.h | 7 + hal/include/HAL/HAL.h | 6 +- hal/include/HAL/I2C.h | 7 + hal/include/HAL/Interrupts.h | 7 + hal/include/HAL/Notifier.h | 7 + hal/include/HAL/PDP.h | 7 + hal/include/HAL/PWM.h | 7 + hal/include/HAL/Power.h | 7 + hal/include/HAL/Relay.h | 7 + hal/include/HAL/SPI.h | 7 + hal/include/HAL/SPIAccumulator.h | 7 + hal/include/HAL/Semaphore.h | 7 + hal/include/HAL/SerialPort.h | 7 + hal/include/HAL/Solenoid.h | 7 + hal/include/HAL/Task.h | 7 + hal/include/HAL/Utilities.h | 7 + hal/include/HAL/cpp/Resource.h | 7 +- hal/include/HAL/cpp/Semaphore.h | 7 + hal/include/Log.h | 7 + hal/lib/shared/HAL.cpp | 8 + hal/lib/sim/HALDesktop.cpp | 9 +- license-update.py | 131 ++++++ wpilibj/src/athena/cpp/lib/CompressorJNI.cpp | 408 +++++++++--------- .../livewindow/LiveWindowComponent.java | 7 + .../wpilibj/MockRobotStateInterface.java | 7 + .../wpi/first/wpilibj/PIDToleranceTest.java | 7 + .../wpi/first/wpilibj/UnitTestUtility.java | 7 + 37 files changed, 575 insertions(+), 214 deletions(-) create mode 100755 license-update.py diff --git a/hal/include/HAL/Accelerometer.h b/hal/include/HAL/Accelerometer.h index ac17a9fb76..e84653b057 100644 --- a/hal/include/HAL/Accelerometer.h +++ b/hal/include/HAL/Accelerometer.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once enum AccelerometerRange { diff --git a/hal/include/HAL/AnalogAccumulator.h b/hal/include/HAL/AnalogAccumulator.h index 612bd2944c..0a1edd5e0a 100644 --- a/hal/include/HAL/AnalogAccumulator.h +++ b/hal/include/HAL/AnalogAccumulator.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/AnalogInput.h b/hal/include/HAL/AnalogInput.h index 1033676a1d..fdd0aa5698 100644 --- a/hal/include/HAL/AnalogInput.h +++ b/hal/include/HAL/AnalogInput.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/AnalogOutput.h b/hal/include/HAL/AnalogOutput.h index c6ab590388..203e1d9c0f 100644 --- a/hal/include/HAL/AnalogOutput.h +++ b/hal/include/HAL/AnalogOutput.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/AnalogTrigger.h b/hal/include/HAL/AnalogTrigger.h index 38a4143d2d..1500121fb5 100644 --- a/hal/include/HAL/AnalogTrigger.h +++ b/hal/include/HAL/AnalogTrigger.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/CAN.h b/hal/include/HAL/CAN.h index ba535ec23c..26e36a06e4 100644 --- a/hal/include/HAL/CAN.h +++ b/hal/include/HAL/CAN.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/Compressor.h b/hal/include/HAL/Compressor.h index 1062c0e4c8..cfea35c034 100644 --- a/hal/include/HAL/Compressor.h +++ b/hal/include/HAL/Compressor.h @@ -1,7 +1,9 @@ -/** - * Compressor.h - * Methods for interacting with a compressor with the CAN PCM device - */ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ #include diff --git a/hal/include/HAL/Counter.h b/hal/include/HAL/Counter.h index 2a72bb0cf6..620d4be685 100644 --- a/hal/include/HAL/Counter.h +++ b/hal/include/HAL/Counter.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/DIO.h b/hal/include/HAL/DIO.h index d161279673..56649f078d 100644 --- a/hal/include/HAL/DIO.h +++ b/hal/include/HAL/DIO.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/Encoder.h b/hal/include/HAL/Encoder.h index 8d314c358f..50e872d77c 100644 --- a/hal/include/HAL/Encoder.h +++ b/hal/include/HAL/Encoder.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/Errors.h b/hal/include/HAL/Errors.h index c29ced6254..de8e486b66 100644 --- a/hal/include/HAL/Errors.h +++ b/hal/include/HAL/Errors.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #define CTR_RxTimeout_MESSAGE "CTRE CAN Recieve Timeout" diff --git a/hal/include/HAL/HAL.h b/hal/include/HAL/HAL.h index 8bd2a4d6a1..8f167834ca 100644 --- a/hal/include/HAL/HAL.h +++ b/hal/include/HAL/HAL.h @@ -1,8 +1,10 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2013. All Rights Reserved. */ +/* Copyright (c) FIRST 2013-2016. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ /*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/I2C.h b/hal/include/HAL/I2C.h index 9ebf463d6a..9058243925 100644 --- a/hal/include/HAL/I2C.h +++ b/hal/include/HAL/I2C.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/Interrupts.h b/hal/include/HAL/Interrupts.h index f00415f0b3..b5c559cc5d 100644 --- a/hal/include/HAL/Interrupts.h +++ b/hal/include/HAL/Interrupts.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/Notifier.h b/hal/include/HAL/Notifier.h index b56545e6c8..84c4328e13 100644 --- a/hal/include/HAL/Notifier.h +++ b/hal/include/HAL/Notifier.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/PDP.h b/hal/include/HAL/PDP.h index 1dd78edcb8..50800c4e67 100644 --- a/hal/include/HAL/PDP.h +++ b/hal/include/HAL/PDP.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/PWM.h b/hal/include/HAL/PWM.h index 693386182d..3accb1f7c6 100644 --- a/hal/include/HAL/PWM.h +++ b/hal/include/HAL/PWM.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/Power.h b/hal/include/HAL/Power.h index 00bff60538..9ef4ef3c3e 100644 --- a/hal/include/HAL/Power.h +++ b/hal/include/HAL/Power.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/Relay.h b/hal/include/HAL/Relay.h index b6b4ae59c5..183b0685c9 100644 --- a/hal/include/HAL/Relay.h +++ b/hal/include/HAL/Relay.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/SPI.h b/hal/include/HAL/SPI.h index 30f17d8d1f..f1c74c24b9 100644 --- a/hal/include/HAL/SPI.h +++ b/hal/include/HAL/SPI.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/SPIAccumulator.h b/hal/include/HAL/SPIAccumulator.h index 881f1eb11e..889157881d 100644 --- a/hal/include/HAL/SPIAccumulator.h +++ b/hal/include/HAL/SPIAccumulator.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/Semaphore.h b/hal/include/HAL/Semaphore.h index a6c5a3a3de..dcfe3d46c8 100644 --- a/hal/include/HAL/Semaphore.h +++ b/hal/include/HAL/Semaphore.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include "cpp/priority_condition_variable.h" diff --git a/hal/include/HAL/SerialPort.h b/hal/include/HAL/SerialPort.h index 88adfb94c7..09bed34983 100644 --- a/hal/include/HAL/SerialPort.h +++ b/hal/include/HAL/SerialPort.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/Solenoid.h b/hal/include/HAL/Solenoid.h index 1f9fe1af51..b6309b4713 100644 --- a/hal/include/HAL/Solenoid.h +++ b/hal/include/HAL/Solenoid.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/Task.h b/hal/include/HAL/Task.h index 223bcfa6d1..2420d76eb0 100644 --- a/hal/include/HAL/Task.h +++ b/hal/include/HAL/Task.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/Utilities.h b/hal/include/HAL/Utilities.h index c16c31161b..c2dccce2b3 100644 --- a/hal/include/HAL/Utilities.h +++ b/hal/include/HAL/Utilities.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/cpp/Resource.h b/hal/include/HAL/cpp/Resource.h index 1a7af69faf..9cca6a0afb 100644 --- a/hal/include/HAL/cpp/Resource.h +++ b/hal/include/HAL/cpp/Resource.h @@ -1,9 +1,10 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008. All Rights Reserved. - */ +/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ /*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/HAL/cpp/Semaphore.h b/hal/include/HAL/cpp/Semaphore.h index 3142fc5de3..336d4927d6 100644 --- a/hal/include/HAL/cpp/Semaphore.h +++ b/hal/include/HAL/cpp/Semaphore.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/include/Log.h b/hal/include/Log.h index 1ec12410ae..a03d79db67 100644 --- a/hal/include/Log.h +++ b/hal/include/Log.h @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #include diff --git a/hal/lib/shared/HAL.cpp b/hal/lib/shared/HAL.cpp index 52c7e0719f..8ab8dd8fb8 100644 --- a/hal/lib/shared/HAL.cpp +++ b/hal/lib/shared/HAL.cpp @@ -1,5 +1,13 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + // This file must compile on ALL PLATFORMS. Be very careful what you put in // here. + #include "HAL/HAL.h" #include #include "FRC_NetworkCommunication/FRCComm.h" diff --git a/hal/lib/sim/HALDesktop.cpp b/hal/lib/sim/HALDesktop.cpp index a7398025ef..67aa0a3394 100644 --- a/hal/lib/sim/HALDesktop.cpp +++ b/hal/lib/sim/HALDesktop.cpp @@ -1 +1,8 @@ -// nothing here yet! \ No newline at end of file +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +// nothing here yet! diff --git a/license-update.py b/license-update.py new file mode 100755 index 0000000000..e97d215412 --- /dev/null +++ b/license-update.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python3 + +# If there is already a comment block, a year range through the current year is +# created using the first year in the comment. If there is no comment block, a +# new one is added containing just the current year. + +from datetime import date +import os +import re + +sep = os.sep +# If directory separator is backslash, escape it for regexes +if sep == "\\": + sep += "\\" + +# Files and directories which should be included in or excluded from the update +regexInclude = re.compile("\.cpp$|\.h$|\.hpp$|\.inc$|\.java$") +folderExclude = "build" + sep + "|\.git" + sep + "|gradle" + sep + \ + "|\.gradle" + sep + "|ni-libraries" + sep + "|ctre" + sep + \ + "|frccansae" + sep + "|FRC_FPGA_ChipObject" + sep + \ + "|gtest" + sep + "|msgs" + sep + "|i2clib" + sep + \ + "|NetworkCommunication" + sep + "|ni" + sep + \ + "|spilib" + sep + "|visa" + sep +regexExclude = re.compile(folderExclude + + "|NIIMAQdx\.h$|nivision\.h$|NIVisionJNI\.cpp$|" + "can_proto\.h$|jni\.h$|jni_md\.h$") + +currentYear = str(date.today().year) + +# Recursively create list of files in given directory +files = [os.path.join(dp, f) for dp, dn, fn in + os.walk(os.path.expanduser(".")) for f in fn] + +# Apply regex filters to list +files = [f for f in files if regexInclude.search(f)] +files = [f for f in files if not regexExclude.search(f)] + +if not files: + print("Error: no files to format", file=sys.stderr) + sys.exit(1) + +for name in files: + # List names of files as they are processed if verbose flag was given + if len(sys.argv) > 1 and sys.argv[1] == "-v": + print("Processing", name,) + with open(name, "r", encoding = "ISO-8859-1") as file: + modifyCopyright = False + year = "" + + # Get first line of file + line = file.readline() + + # If first line is copyright comment + if line[0:2] == "/*": + modifyCopyright = True + + # Get next line + line = file.readline() + + # Search for start of copyright year + pos = line.find("20") + + # Extract it if found + if pos != -1: + year = line[pos:pos + 4] + else: + continue + + # Retrieve lines until one past end of comment block + inComment = True + inBlock = True + while inBlock: + if not inComment: + pos = line.find("/*", pos) + if pos != -1: + inComment = True + else: + inBlock = False + else: + pos = line.find("*/", pos) + if pos != -1: + inComment = False + + # This assumes no comments are started on the same line after + # another ends + line = file.readline() + pos = 0 + + with open(name + ".tmp", "w", encoding = "ISO-8859-1") as temp: + # Write first line of comment + temp.write("/*") + for i in range(0, 76): + temp.write("-") + temp.write("*/\n") + + # Write second line of comment + temp.write("/* Copyright (c) FIRST ") + if modifyCopyright and year != currentYear: + temp.write(year) + temp.write("-") + temp.write(currentYear) + temp.write(". All Rights Reserved.") + for i in range(0, 24): + temp.write(" ") + if not modifyCopyright or year == currentYear: + for i in range(0, 5): + temp.write(" ") + temp.write("*/\n") + + # Write rest of lines of comment + temp.write("/* Open Source Software - may be modified and shared by FRC teams. The code */\n" + "/* must be accompanied by the FIRST BSD license file in the root directory of */\n" + "/* the project. */\n" + "/*") + for i in range(0, 76): + temp.write("-") + temp.write("*/\n") + + # If line after comment block isn't empty + if len(line) > 1 and line[0] != " ": + temp.write("\n") + temp.write(line) + + # Copy rest of original file into new one + for line in file: + temp.write(line) + + # Replace old file + os.remove(name) + os.rename(name + ".tmp", name) + diff --git a/wpilibj/src/athena/cpp/lib/CompressorJNI.cpp b/wpilibj/src/athena/cpp/lib/CompressorJNI.cpp index 232838b2ba..fe7f45b26a 100644 --- a/wpilibj/src/athena/cpp/lib/CompressorJNI.cpp +++ b/wpilibj/src/athena/cpp/lib/CompressorJNI.cpp @@ -1,204 +1,204 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2016. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "HAL/HAL.h" -#include "HALUtil.h" -#include "Log.h" -#include "edu_wpi_first_wpilibj_hal_CompressorJNI.h" - -extern "C" { - -/* - * Class: edu_wpi_first_wpilibj_hal_CompressorJNI - * Method: initializeCompressor - * Signature: (B)J - */ -JNIEXPORT jlong JNICALL -Java_edu_wpi_first_wpilibj_hal_CompressorJNI_initializeCompressor( - JNIEnv *env, jclass, jbyte module) { - void *pcm = initializeCompressor(module); - return (jlong)pcm; -} - -/* - * Class: edu_wpi_first_wpilibj_hal_CompressorJNI - * Method: checkCompressorModule - * Signature: (B)Z - */ -JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_wpilibj_hal_CompressorJNI_checkCompressorModule( - JNIEnv *env, jclass, jbyte module) { - return checkCompressorModule(module); -} - -/* - * Class: edu_wpi_first_wpilibj_hal_CompressorJNI - * Method: getCompressor - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressor( - JNIEnv *env, jclass, jlong pcm_pointer) { - int32_t status = 0; - bool val = getCompressor((void *)pcm_pointer, &status); - CheckStatus(env, status); - return val; -} - -/* - * Class: edu_wpi_first_wpilibj_hal_CompressorJNI - * Method: setClosedLoopControl - * Signature: (JZ)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_wpilibj_hal_CompressorJNI_setClosedLoopControl( - JNIEnv *env, jclass, jlong pcm_pointer, jboolean value) { - int32_t status = 0; - setClosedLoopControl((void *)pcm_pointer, value, &status); - CheckStatus(env, status); -} - -/* - * Class: edu_wpi_first_wpilibj_hal_CompressorJNI - * Method: getClosedLoopControl - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getClosedLoopControl( - JNIEnv *env, jclass, jlong pcm_pointer) { - int32_t status = 0; - bool val = getClosedLoopControl((void *)pcm_pointer, &status); - CheckStatus(env, status); - return val; -} - -/* - * Class: edu_wpi_first_wpilibj_hal_CompressorJNI - * Method: getPressureSwitch - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getPressureSwitch( - JNIEnv *env, jclass, jlong pcm_pointer) { - int32_t status = 0; - bool val = getPressureSwitch((void *)pcm_pointer, &status); - CheckStatus(env, status); - return val; -} - -/* - * Class: edu_wpi_first_wpilibj_hal_CompressorJNI - * Method: getCompressorCurrent - * Signature: (J)F - */ -JNIEXPORT jfloat JNICALL -Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrent( - JNIEnv *env, jclass, jlong pcm_pointer) { - int32_t status = 0; - float val = getCompressorCurrent((void *)pcm_pointer, &status); - CheckStatus(env, status); - return val; -} - -/* - * Class: edu_wpi_first_wpilibj_hal_CompressorJNI - * Method: getCompressorCurrentTooHighFault - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrentTooHighFault( - JNIEnv *env, jclass, jlong pcm_pointer) { - int32_t status = 0; - bool val = getCompressorCurrentTooHighFault((void *)pcm_pointer, &status); - CheckStatus(env, status); - return val; -} - -/* - * Class: edu_wpi_first_wpilibj_hal_CompressorJNI - * Method: getCompressorCurrentTooHighStickyFault - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrentTooHighStickyFault( - JNIEnv *env, jclass, jlong pcm_pointer) { - int32_t status = 0; - bool val = - getCompressorCurrentTooHighStickyFault((void *)pcm_pointer, &status); - CheckStatus(env, status); - return val; -} - -/* - * Class: edu_wpi_first_wpilibj_hal_CompressorJNI - * Method: getCompressorShortedStickyFault - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorShortedStickyFault( - JNIEnv *env, jclass, jlong pcm_pointer) { - int32_t status = 0; - bool val = getCompressorShortedStickyFault((void *)pcm_pointer, &status); - CheckStatus(env, status); - return val; -} - -/* - * Class: edu_wpi_first_wpilibj_hal_CompressorJNI - * Method: getCompressorShortedFault - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorShortedFault( - JNIEnv *env, jclass, jlong pcm_pointer) { - int32_t status = 0; - bool val = getCompressorShortedFault((void *)pcm_pointer, &status); - CheckStatus(env, status); - return val; -} - -/* - * Class: edu_wpi_first_wpilibj_hal_CompressorJNI - * Method: getCompressorNotConnectedStickyFault - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorNotConnectedStickyFault( - JNIEnv *env, jclass, jlong pcm_pointer) { - int32_t status = 0; - bool val = getCompressorNotConnectedStickyFault((void *)pcm_pointer, &status); - CheckStatus(env, status); - return val; -} - -/* - * Class: edu_wpi_first_wpilibj_hal_CompressorJNI - * Method: getCompressorNotConnectedFault - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorNotConnectedFault( - JNIEnv *env, jclass, jlong pcm_pointer) { - int32_t status = 0; - bool val = getCompressorNotConnectedFault((void *)pcm_pointer, &status); - CheckStatus(env, status); - return val; -} -/* - * Class: edu_wpi_first_wpilibj_hal_CompressorJNI - * Method: clearAllPCMStickyFaults - * Signature: (J)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_wpilibj_hal_CompressorJNI_clearAllPCMStickyFaults( - JNIEnv *env, jclass, jlong pcm_pointer) { - int32_t status = 0; - clearAllPCMStickyFaults((void *)pcm_pointer, &status); - CheckStatus(env, status); -} - -} // extern "C" +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "HAL/HAL.h" +#include "HALUtil.h" +#include "Log.h" +#include "edu_wpi_first_wpilibj_hal_CompressorJNI.h" + +extern "C" { + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: initializeCompressor + * Signature: (B)J + */ +JNIEXPORT jlong JNICALL +Java_edu_wpi_first_wpilibj_hal_CompressorJNI_initializeCompressor( + JNIEnv *env, jclass, jbyte module) { + void *pcm = initializeCompressor(module); + return (jlong)pcm; +} + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: checkCompressorModule + * Signature: (B)Z + */ +JNIEXPORT jboolean JNICALL +Java_edu_wpi_first_wpilibj_hal_CompressorJNI_checkCompressorModule( + JNIEnv *env, jclass, jbyte module) { + return checkCompressorModule(module); +} + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: getCompressor + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressor( + JNIEnv *env, jclass, jlong pcm_pointer) { + int32_t status = 0; + bool val = getCompressor((void *)pcm_pointer, &status); + CheckStatus(env, status); + return val; +} + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: setClosedLoopControl + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL +Java_edu_wpi_first_wpilibj_hal_CompressorJNI_setClosedLoopControl( + JNIEnv *env, jclass, jlong pcm_pointer, jboolean value) { + int32_t status = 0; + setClosedLoopControl((void *)pcm_pointer, value, &status); + CheckStatus(env, status); +} + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: getClosedLoopControl + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getClosedLoopControl( + JNIEnv *env, jclass, jlong pcm_pointer) { + int32_t status = 0; + bool val = getClosedLoopControl((void *)pcm_pointer, &status); + CheckStatus(env, status); + return val; +} + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: getPressureSwitch + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getPressureSwitch( + JNIEnv *env, jclass, jlong pcm_pointer) { + int32_t status = 0; + bool val = getPressureSwitch((void *)pcm_pointer, &status); + CheckStatus(env, status); + return val; +} + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: getCompressorCurrent + * Signature: (J)F + */ +JNIEXPORT jfloat JNICALL +Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrent( + JNIEnv *env, jclass, jlong pcm_pointer) { + int32_t status = 0; + float val = getCompressorCurrent((void *)pcm_pointer, &status); + CheckStatus(env, status); + return val; +} + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: getCompressorCurrentTooHighFault + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrentTooHighFault( + JNIEnv *env, jclass, jlong pcm_pointer) { + int32_t status = 0; + bool val = getCompressorCurrentTooHighFault((void *)pcm_pointer, &status); + CheckStatus(env, status); + return val; +} + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: getCompressorCurrentTooHighStickyFault + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrentTooHighStickyFault( + JNIEnv *env, jclass, jlong pcm_pointer) { + int32_t status = 0; + bool val = + getCompressorCurrentTooHighStickyFault((void *)pcm_pointer, &status); + CheckStatus(env, status); + return val; +} + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: getCompressorShortedStickyFault + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorShortedStickyFault( + JNIEnv *env, jclass, jlong pcm_pointer) { + int32_t status = 0; + bool val = getCompressorShortedStickyFault((void *)pcm_pointer, &status); + CheckStatus(env, status); + return val; +} + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: getCompressorShortedFault + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorShortedFault( + JNIEnv *env, jclass, jlong pcm_pointer) { + int32_t status = 0; + bool val = getCompressorShortedFault((void *)pcm_pointer, &status); + CheckStatus(env, status); + return val; +} + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: getCompressorNotConnectedStickyFault + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorNotConnectedStickyFault( + JNIEnv *env, jclass, jlong pcm_pointer) { + int32_t status = 0; + bool val = getCompressorNotConnectedStickyFault((void *)pcm_pointer, &status); + CheckStatus(env, status); + return val; +} + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: getCompressorNotConnectedFault + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorNotConnectedFault( + JNIEnv *env, jclass, jlong pcm_pointer) { + int32_t status = 0; + bool val = getCompressorNotConnectedFault((void *)pcm_pointer, &status); + CheckStatus(env, status); + return val; +} +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: clearAllPCMStickyFaults + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_edu_wpi_first_wpilibj_hal_CompressorJNI_clearAllPCMStickyFaults( + JNIEnv *env, jclass, jlong pcm_pointer) { + int32_t status = 0; + clearAllPCMStickyFaults((void *)pcm_pointer, &status); + CheckStatus(env, status); +} + +} // extern "C" diff --git a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/livewindow/LiveWindowComponent.java b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/livewindow/LiveWindowComponent.java index e00fe91ce0..93b2aa4877 100644 --- a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/livewindow/LiveWindowComponent.java +++ b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/livewindow/LiveWindowComponent.java @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + package edu.wpi.first.wpilibj.livewindow; /** diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/MockRobotStateInterface.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/MockRobotStateInterface.java index fbace75fe4..f899365dfa 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/MockRobotStateInterface.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/MockRobotStateInterface.java @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + package edu.wpi.first.wpilibj; /** diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/PIDToleranceTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/PIDToleranceTest.java index effb5751d5..06b3ae7e4b 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/PIDToleranceTest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/PIDToleranceTest.java @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + package edu.wpi.first.wpilibj; import org.junit.After; diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/UnitTestUtility.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/UnitTestUtility.java index 8c55ad136a..0b86950f4e 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/UnitTestUtility.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/UnitTestUtility.java @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + package edu.wpi.first.wpilibj; import com.google.common.base.Stopwatch;