rust/src/etc/licenseck.py

57 lines
2.1 KiB
Python
Raw Normal View History

# Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2013-01-18 01:28:42 -06:00
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
2015-01-22 22:40:15 -06:00
import re
import os
2013-01-18 01:28:42 -06:00
2015-01-22 22:40:15 -06:00
license_re = re.compile(
u"""(#|//) Copyright .* The Rust Project Developers. See the COPYRIGHT
\\1 file at the top-level directory of this distribution and at
\\1 http://rust-lang.org/COPYRIGHT.
\\1
\\1 Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
\\1 http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
\\1 <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
\\1 option. This file may not be copied, modified, or distributed
\\1 except according to those terms.""")
2013-01-18 01:28:42 -06:00
exceptions = [
std: Second pass stabilization for `comm` This commit is a second pass stabilization for the `std::comm` module, performing the following actions: * The entire `std::comm` module was moved under `std::sync::mpsc`. This movement reflects that channels are just yet another synchronization primitive, and they don't necessarily deserve a special place outside of the other concurrency primitives that the standard library offers. * The `send` and `recv` methods have all been removed. * The `send_opt` and `recv_opt` methods have been renamed to `send` and `recv`. This means that all send/receive operations return a `Result` now indicating whether the operation was successful or not. * The error type of `send` is now a `SendError` to implement a custom error message and allow for `unwrap()`. The error type contains an `into_inner` method to extract the value. * The error type of `recv` is now `RecvError` for the same reasons as `send`. * The `TryRecvError` and `TrySendError` types have had public reexports removed of their variants and the variant names have been tweaked with enum namespacing rules. * The `Messages` iterator is renamed to `Iter` This functionality is now all `#[stable]`: * `Sender` * `SyncSender` * `Receiver` * `std::sync::mpsc` * `channel` * `sync_channel` * `Iter` * `Sender::send` * `Sender::clone` * `SyncSender::send` * `SyncSender::try_send` * `SyncSender::clone` * `Receiver::recv` * `Receiver::try_recv` * `Receiver::iter` * `SendError` * `RecvError` * `TrySendError::{mod, Full, Disconnected}` * `TryRecvError::{mod, Empty, Disconnected}` * `SendError::into_inner` * `TrySendError::into_inner` This is a breaking change due to the modification of where this module is located, as well as the changing of the semantics of `send` and `recv`. Most programs just need to rename imports of `std::comm` to `std::sync::mpsc` and add calls to `unwrap` after a send or a receive operation. [breaking-change]
2014-12-23 13:53:35 -06:00
"libstd/sync/mpsc/mpsc_queue.rs", # BSD
"libstd/sync/mpsc/spsc_queue.rs", # BSD
"test/bench/shootout-binarytrees.rs", # BSD
"test/bench/shootout-chameneos-redux.rs", # BSD
"test/bench/shootout-fannkuch-redux.rs", # BSD
"test/bench/shootout-fasta.rs", # BSD
"test/bench/shootout-fasta-redux.rs", # BSD
"test/bench/shootout-k-nucleotide.rs", # BSD
"test/bench/shootout-mandelbrot.rs", # BSD
"test/bench/shootout-meteor.rs", # BSD
"test/bench/shootout-nbody.rs", # BSD
"test/bench/shootout-regex-dna.rs", # BSD
"test/bench/shootout-reverse-complement.rs", # BSD
"test/bench/shootout-spectralnorm.rs", # BSD
"test/bench/shootout-threadring.rs", # BSD
2013-01-18 01:28:42 -06:00
]
def check_license(name, contents):
name = os.path.normpath(name)
# Whitelist check
if any(name.endswith(os.path.normpath(e)) for e in exceptions):
return True
2013-01-18 01:28:42 -06:00
# Xfail check
2013-01-18 01:28:42 -06:00
firstlineish = contents[:100]
if "ignore-license" in firstlineish:
2013-01-18 01:28:42 -06:00
return True
# License check
boilerplate = contents[:500]
2015-01-22 22:40:15 -06:00
return bool(license_re.search(boilerplate))